Discuss an algorithm to traverse a tree, depth first.
Java Trees Interview Questions
Write a function that takes as input a binary tree, and returns the length of the longest path.
For example, in this binary tree:
1
/ \
2 3
/
5
the answer is 2, since the path from vertex 1 to vertex 5 involves two edge traversals.
Write function that takes a binary tree and efficiently returns the Nth smallest element.
For example, if N=4, and the tree looks like:
3
/ \
2 5
/ / \
1 4 6
The function should return 4.