Efficient Array Storage for Binary Tree

Posted by Sundararajan S on Stack Overflow See other posts from Stack Overflow or by Sundararajan S
Published on 2010-04-20T14:07:47Z Indexed on 2010/04/20 14:13 UTC
Read the original article Hit count: 252

Filed under:

We have to write the nodes of a binary tree to a file. What is the most space efficient way of writing a binary tree . We can store it in array format with parent in position 'i' and its childs in 2i,2i+1. But this will waste lot of space in case of sparse binary trees.

© Stack Overflow or respective owner

Related posts about algorithm