employer cover photo
employer logo
employer logo

Palantir Technologies

Is this your company?

Palantir Technologies Interview Question

Iterative in-order search?

Interview Answers

Anonymous

Dec 9, 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

Anonymous

Nov 1, 2010

Use a stack.