Created
October 18, 2018 17:50
-
-
Save Khalefa/8532081f04bb18bbe941ceebd69a563a to your computer and use it in GitHub Desktop.
q1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void printTree2(BinaryNode * r) { | |
if(r==nullptr) return; | |
else { | |
queue<BinaryNode*> q; | |
q.push(r); | |
while (!q.empty()){ | |
BinaryNode *n=q.back(); | |
q.pop(); | |
cout << n->element << endl; | |
if(n->left!=nullptr)q.push(n->left); | |
if(n->right!=nullptr)q.push(n->right); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment