[algogeeks] Re: Java Tree Datastructure

2012-02-07 Thread WgpShashank
@DT Use BFS (Queue) , try it. -- *Thanks Shashank Mani Narayan Computer Science Engineering Birla Institute of Technology,Mesra ** Founder Cracking The Code Lab http://shashank7s.blogspot.com/* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

Re: [algogeeks] Re: Java Tree Datastructure

2012-02-07 Thread atul anand
algo will be something like this:- i=0; arr[i]=root; enqueue(root); while queue is not empty temp=dequeue(); i =search for element temp in array temp and return it index if(temp-left!=NULL) { arr[2*i+1]=temp-left; enqueue(temp-left); }

[algogeeks] Re: Java Tree Datastructure

2012-02-07 Thread DT
Thanks for the reply. But is this solution the most efficient one or do we have better space complexity algos available? The code below will introduce array indexes with empty values whenever the left/right child is null. On Feb 7, 2:06 pm, atul anand atul.87fri...@gmail.com wrote: algo will be

Re: [algogeeks] Re: Java Tree Datastructure

2012-02-07 Thread atul anand
you can use hashtable , hash at calculated index, no need of saving empty spaces. On Tue, Feb 7, 2012 at 4:38 PM, DT pa7...@gmail.com wrote: Thanks for the reply. But is this solution the most efficient one or do we have better space complexity algos available? The code below will introduce