Good question. The problem is not well-defined. It's possible that
75 should be omitted because there are deeper subtrees to the left and
right. But we'll never know for sure because examples don't make a
good definition.
On Apr 8, 2:29 pm, atul anand atul.87fri...@gmail.com wrote:
i guess
75 is omitted because its the border. Think of border like putting an
elastic rubber band around the tree. Print the nodes being touched by the
rubber.
On Monday, 9 April 2012 08:12:48 UTC+5:30, Gene wrote:
Good question. The problem is not well-defined. It's possible that
75 should be
then one way to do this would be something like this :-
find h1=maxHeight of root-left
find h2=maxHeight of root-right
leave root and first print left and right subtree of the root
now call print(root-left)
a) if root-left==NULL root-right!=NULL currentHeighth1
then print current
@above : correction in now call print(root-right) , highlighted below
a) if root-right==NULL *root-left!=NULL* currentHeighth2
On Mon, Apr 9, 2012 at 10:53 AM, atul anand atul.87fri...@gmail.com wrote:
then one way to do this would be something like this :-
find h1=maxHeight of root-left
above you need to print only those leaf nodes which are at height h1 or h2.
actually some of the cases are missed in above algo.which would result in
wrong output.
i will post the solution , once taking into account of all cases.
On Mon, Apr 9, 2012 at 10:56 AM, atul anand atul.87fri...@gmail.com