suppose both trees contains n nodes
then converting to dll both the trees O(n) + O(n)
then merging two dll's O(n)
converting back to tree also O(2*n)=O(n)......// not sure about it

code for converting tree to dll
node * bsttolist(node *root){
          if(root==NULL) return NULL;
          node *l=bsttolist(root->left);
          node *r=bsttolist(root->right);
          root->left=root;
          root->right=root;
          append(l,root);
          append(l,r);
          return l;
}


here append function merges two circular doubly linked lists , you can make
that on your own




On Mon, Jul 26, 2010 at 5:52 PM, Manjunath Manohar <manjunath.n...@gmail.com
> wrote:

> @jalaj: could u pls elaborate on that a bit more..will it have the
> complexity of O(n logn logn), and also can u provide the pseudocode pls..
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
With Regards,
Jalaj Jaiswal
+919026283397
B.TECH IT
IIIT ALLAHABAD

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@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.

Reply via email to