Skip to content

Instantly share code, notes, and snippets.

@Khalefa
Created October 18, 2018 17:50
Show Gist options
  • Save Khalefa/8532081f04bb18bbe941ceebd69a563a to your computer and use it in GitHub Desktop.
Save Khalefa/8532081f04bb18bbe941ceebd69a563a to your computer and use it in GitHub Desktop.
q1
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