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 <ankit.agarwal.n...@gmail.com>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 <ankuj2...@gmail.com> 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 algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.