meetsaurabhsrivastava
BAN USER
Comments (4)
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
Sorry the formatting is not evident... in the above example, both 2's don't have a left child, and 3's are their right children..
- meetsaurabhsrivastava July 18, 2011Comment hidden because of low score. Click to expand.
0
of 0 vote
Your Solution is right, but i think it needs slight modification... think of such a case:
1
2 2
3 3
The 3rd level is symmetric on its own, but overall, tree is not...
we can change your solution slightly to cater such cases. whenever you encounter a NULL, put some known character, say -1 in case of tree with +ve integers. We can stop the algorithm if we see a case of non symmetry or get a Layer with all -1's !!
Comment hidden because of low score. Click to expand.
0
of 0 vote
Sorting means you are taking O nlgn
- meetsaurabhsrivastava July 17, 2011Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
Depends on the type of 'left' and 'right'. I guess, here it would be node, coz left and right can be either another internal node, or a terminal node.
- meetsaurabhsrivastava July 20, 2011In that case, calling {left.height()} or {right.height()} will be invalid !!