Question d’entretien chez Aruba Networks

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

Réponse à la question d'entretien

Utilisateur anonyme

15 oct. 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