can proceed like this...writing it quite fast, may have issues...

lets say T2 is being merged into T1
//assumption, trees have different data values
struct node * merge(struct node *pT1, struct node *pT2)
{
  if (!pT2) return NULL;
struct node *ptemp=NULL;
  if (pT2->data <pT1->data)
  {
      ptemp = pT2->right;
      pT2->right =NULL;
      pT1->left = merge(pT1->left, pT2);
      pT1->right = merge(pT1, ptemp);

  }
  else {
    ptemp = pT2->left;
    pT2->left = NULL;
    pT1->right= merge(pT1->right, pT2);
    pT1->left= merge(pT1,ptemp);
  }

}



On 7/26/10, 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.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Best Regards
Ashish Goel
"Think positive and find fuel in failure"
+919985813081
+919966006652

-- 
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