whats the final answer guys? Level order traversal??

On Tue, Aug 30, 2011 at 12:56 AM, Don <dondod...@gmail.com> wrote:

> I'm not sure if this is what you are looking for, but I once came up
> with a way to save a binary tree in such a way that when it is
> rebuilt, it will be balanced. You don't get back the exact same tree
> with all the nodes in the same position, but you do get the same nodes
> in a balanced configuration.
>
> Start by doing an inorder traversal and storing each node sequentially
> in an array.
> Then call a recursive function called saveTree(first, last), where
> first and last are the first and last indices of the array.
> saveTree does the following if:
> write middle item of array to the file
> call saveTree on left half of array
> call saveTree on right half of array
>
> When you rebuild the tree adding the nodes in the order in which they
> occur in the file, the resulting tree will be balanced.
>
> Don
>
> On Aug 28, 1:29 am, rohit <rajuljain...@gmail.com> wrote:
> > How to save a binary search tree space efficiently and built it
> > again , just tell any idea.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@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.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@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