@mohit: your algo will add assurance that the tree is balanced.. otherwise
ankit's approach is sufficient.

On Sat, Nov 5, 2011 at 8:49 PM, mohit verma <[email protected]> wrote:

> another way is : convert binary tree to link list , sort the list and
> using divide  and conquer approach create the BST.
>
> From link list to BST : find mid of sorted link list , make it root node
> and put left of it to recursive(list,start,mid->prev) and
> root->right=recursive(list,mid->next,last);
>
> Let me know if something is wrong in this approach.
>
>
> On Sat, Nov 5, 2011 at 3:48 PM, ankit agarwal <
> [email protected]> wrote:
>
>> I think it's the only way as you need to traverse the entire binary
>> tree to do it.
>>
>> On Oct 31, 9:45 pm, Ankuj Gupta <[email protected]> wrote:
>> > How to convert a Binary tree to BST ? Naive way is to create each node
>> > of  Binary tree one by one and keep on creating the BST.
>>
>> --
>> 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.
>>
>>
>
>
> --
> Mohit
>
>  --
> 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