ananth.sadanand
BAN USER
Comments (3)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
^ That is exactly how I interpreted this question. You can never correctly tell if a node forms a binary tree unless it is a root node in which case we can do a traversal and check for b-tree'ness.
Since it is a random node, we have to look at the 'possibility' that it forms either of the two.
In a real life situation, I presume this would be some optimization over checking the whole tree or list.
Comment hidden because of low score. Click to expand.
0
of 0 vote
the 'input->next ! = input->prev' condition checks if the input node points to two different locations in memory which would mean there is a possibility that it forms a binary tree node. Given a single node, that is the only condition you can check.
- ananth.sadanand December 16, 2013Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
The question speaks of a 'random' node so it need not necessarily be a root node in which case your recursion solution does not hold for all possible cases.
- ananth.sadanand December 16, 2013