Question d’entretien chez Palantir Technologies

Iterative in-order search?

Réponses aux questions d'entretien

Utilisateur anonyme

9 déc. 2010

Stack s = new Stack(); public void inOrderWithoutRecursion(node n) { while (!s.isEmpty() || n != null) { if (n != null) {// this is a normal call, recurse s.push(n); n = n.left; } else // we're returning: pop and print the current node { n = s.pop(); System.out.println(n.value); n = n.right; } } }

2

Utilisateur anonyme

1 nov. 2010

Use a stack.