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 sweetdivya@gmail.com wrote: thanks a lot to all for their replies.. On 9 May 2010 11:23, rahul rai raikra...@gmail.com wrote: can anyone give me links to

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 raikra...@gmail.com 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 aruntendulkar2...@gmail.com wrote: This does not create a balanced tree

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 aruntendulkar2...@gmail.com 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)

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 stdlib.h #includeunistd.h #include stdio.h #define TEST2 #ifdef TEST1 int arr[] = { 1,2,3,4,5,6,7}; int max_elems

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,

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

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

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;

[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