Google Interview Question: The question was on n-ary tre... | Glassdoor

Interview Question

Software Engineer Interview New York, NY

The question was on n-ary tree data stream. Not unexpected

 , but there was a misunderstanding between myself and the interviewer. The question is to find the head of the tree given a data stream of key value pairs.

Interview Answer

1 Answer


think of the tree as an acyclic graph, use dfs to obtain topological order, head of the tree is the first node in topological order

Cathy Liu on Jun 8, 2014

Add Answers or Comments

To comment on this, Sign In or Sign Up.