No, you are wrong here.

The inorder sequence should be 5 -> 25 -> 30 -> 50 -> 55 -> 60 ->75.

The preorder sequence should be 50 -> 25 -> 5 -> 30 -> 60 -> 55 -> 75

The postorder sequence should be 5 -> 30 -> 25 -> 55 -> 75 -> 60 -> 50

Below is the analysis (from wikipedia):

To traverse a non-empty binary tree in preorder, perform the following
operations recursively at each node, starting with the root node:

   1. Visit the root.
   2. Traverse the left subtree.
   3. Traverse the right subtree.

To traverse a non-empty binary tree in inorder (symmetric), perform
the following operations recursively at each node:

   1. Traverse the left subtree.
   2. Visit the root.
   3. Traverse the right subtree.

To traverse a non-empty binary tree in postorder, perform the
following operations recursively at each node:

   1. Traverse the left subtree.
   2. Traverse the right subtree.
   3. Visit the root.

Go to http://en.wikipedia.org/wiki/Traversal and see details.

On Thu, Aug 26, 2010 at 11:59 AM, Chi Hoang <[email protected]> wrote:
> Am 26.08.2010 18:59, schrieb krazee koder:
>> Give all possible methods to flatten a binary tree to a linked list.
>>
>> for eg.
>>
>>        50
>>      /     \
>>   25      60
>> /     \     /  \
>> 5    30  55  75
>>
>>
>> should be flattened to  5->25->30->50->55->60->75
>>
>> PS: note that the tree should be converted to the LL and no separate
>> LL should be formed.
>>
>>
>  If the above example is preorder it must be:
>
> 5->25->30->55->60->75->50
>
> because preorder is looking to me like nested sets or celco trees.
>
> Postorder would be:
>
> 50->25->5->30->60->55->75
>
> Inorder:
>
> 5->25->50->30->60->55->75
>
> or
>
> 5->25->50->40->55->60->75
>
> I'm not to sure. Pls correct me if I'm wrong!
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to