Google Interview Question

Return k smallest element in a tree

Interview Answers

Anonymous

Jun 16, 2016

DFS inorder return first k visited nodes (using auxiliary array)

1

Anonymous

Apr 23, 2015

using a rather complicated recursion.

Anonymous

Jun 27, 2015

look number of values on the left of the current node, if adding this node we get k - this is the node we are looking for.

Anonymous

Dec 17, 2015

Probably a heap is the right way to go