Created
March 4, 2015 05:50
-
-
Save rohith2506/872fa6eddda59f30956e to your computer and use it in GitHub Desktop.
iterative pre order traversal
This file contains hidden or 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 preorder(root){ | |
stk.push(root); | |
while(!stk.empty()){ | |
cout << stk.top(); | |
stk.pop(); | |
if(root -> right) stk.push(root->right); | |
if(root -> left) stk.push(root -> left); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment