I think a BST can be itself considered as a general tree. In case, we need to convert a general tree to BST :- The approach is :- 1- convert the general tree into a double linked list inplace - O(n) 2- Now apply merge sort on the doubly linked list - O(n) 2- Now convert the doubly linked list to BST using bottom-up approach -O(n)
all working codes can be found at www.geeksforgeeks.org -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/_f5nd0vFmKoJ. 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.