This was asked in Google Interview.
Given a list of parent-child relationships, build a tree out of it.
Example Input:
80 19
50 20
20 15
80 16
50 80
20 17
You should return the following tree:
50
/ \
20 80
/ \ / \
15 17 19 16PS: This doesn't have to be a binary tree. You need to return a root node.