i donot think that the link provided is for the same problem, the link
provides a solution to balance a tree whereas this problem is to merge
two BST without any limitation on the balance factor
having said that th balancing the tree itself is an interesting
problem and i must say that the documen
Jalaj,
How do you convert a Circular DLL to BST??
Please refer my solution, and coorect it if needed;)
Regards
Ashish
On 7/26/10, jalaj jaiswal wrote:
> 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 t
@ashish..nice code..i think the complexity is O(n logn ) right.. am i
right??
--
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
algo
@jalaj..thanks for ur help..really appreciate it.. :)
--
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...@google
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 data)
{
ptemp = p
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
@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...@google
convert both to dll and merge the two dll's and
finally create the tree from a dll recursively
On Mon, Jul 26, 2010 at 5:16 PM, Manjunath Manohar wrote:
> no just a BT, the tree can be in any form..it need not be balanced also..
>
> --
> You received this message because you are subscribed to th
no just a BT, the tree can be in any form..it need not be balanced also..
--
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
algogeek