Re: [algogeeks] tree from linked list

2010-05-13 Thread divya jain
the best approach to it is to build a balanced tree from bottom to up rather than top to bottom. On 12 May 2010 22:47, divya jain wrote: > thanks a lot to all for their replies.. > > > On 9 May 2010 11:23, rahul rai wrote: > >> can anyone give me links to more educative and active groups like >

Re: [algogeeks] tree from linked list

2010-05-12 Thread divya jain
thanks a lot to all for their replies.. On 9 May 2010 11:23, rahul rai wrote: > can anyone give me links to more educative and active groups like algogeeks > > On Sun, May 9, 2010 at 2:11 AM, Arun prasath > wrote: > > This does not create a balanced tree but ensures that every element in > the

Re: [algogeeks] tree from linked list

2010-05-09 Thread rahul rai
can anyone give me links to more educative and active groups like algogeeks On Sun, May 9, 2010 at 2:11 AM, Arun prasath wrote: > This does not create a balanced tree but ensures that every element in the > tree is accessible by lg(n) time. > > Time : Complexity   O(n) > > > [a...@91blore-srv1 ~]

Re: [algogeeks] tree from linked list

2010-05-08 Thread Arun prasath
This does not create a balanced tree but ensures that every element in the tree is accessible by lg(n) time. Time : Complexity O(n) [a...@91blore-srv1 ~]$ cat recursion.c #include #include #include #define TEST2 #ifdef TEST1 int arr[] = { 1,2,3,4,5,6,7}; int max_elems = sizeof(arr)/sizeof(ar

Re: [algogeeks] tree from linked list

2010-05-07 Thread Rohit Saraf
i guess the rotation solution i gave will take O(n) with the list as well (btw.. u can convert a list to array :P) -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14

Re: [algogeeks] tree from linked list

2010-05-07 Thread varun bhatia
Cant we do something like this: Make the middle element as root, middle element of the left side as its left child and mid of the right half as its right child. and so on for the left and right subtrees. it would bring out a balanced tree without rotations.. On Mon, Ma

Re: [algogeeks] tree from linked list

2010-05-07 Thread divya jain
it is easy to traverse the array. as u can directly reach middle element in constant time. but for linked list u cant do dat. so the time complexity of both the solution given above are O(nlogn). is there any other better complexity solution. On 3 May 2010 17:41, jalaj jaiswal wrote: > for simpl

Re: [algogeeks] tree from linked list

2010-05-03 Thread jalaj jaiswal
for simplicity in writin algo i've taken sorted array instead of list struct node * create( int *sorted,number of elements){ struct node *temp,*left,*right; int tempii[100],tempiii[100]; if(number of elemnts ==0) return NULL; temp->data=sorted[

Re: [algogeeks] tree from linked list

2010-05-03 Thread Rohit Saraf
1) Make the middle element the root. Recursively make the left and right subtrees from the left and right halves of the link list. 2) Implement balanced insertion in trees (via rotations on every step...). Now insert each element -- Rohit Saraf

[algogeeks] tree from linked list

2010-05-02 Thread divya
u are given a sorted lnked list construct a balanced binary search tree from 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 a