Frage im Vorstellungsgespräch bei Aruba Networks

Binary search tree traversal without recursion (parent pointer provided)?

Antwort im Vorstellungsgespräch

Anonym

15. Okt. 2012

use stack for iteratively going through nodes. //Stack S; While(1) { while(root) { //print root->data push (S,root); root = root->left; } if(isemptystack(S) return; root = Pop(S); //after left subtree, goto right subtree root = root->right; }

1