Skip to main content
added 202 characters in body
Source Link
user16034
user16034

There is no standard way to represent data structures of this kind.

One approach could be to sequentially write the content of every node during a preorderinorder traversal, together with information aboud the tree structure.

I guess (this needs to be checked) that two bits indicating if a node has left and right children is enough to reconstruct correctly while reading back.


Note that it some applications, you needn't keep the original tree structure but only the content: for instance for a balanced search tree, you can just build a new tree from the keys.

There is no standard way to represent data structures of this kind.

One approach could be to sequentially write the content of every node during a preorder traversal, together with information aboud the tree structure.

I guess (this needs to be checked) that two bits indicating if a node has left and right children is enough to reconstruct correctly while reading back.

There is no standard way to represent data structures of this kind.

One approach could be to sequentially write the content of every node during a inorder traversal, together with information aboud the tree structure.

I guess (this needs to be checked) that two bits indicating if a node has left and right children is enough to reconstruct correctly while reading back.


Note that it some applications, you needn't keep the original tree structure but only the content: for instance for a balanced search tree, you can just build a new tree from the keys.

Source Link
user16034
user16034

There is no standard way to represent data structures of this kind.

One approach could be to sequentially write the content of every node during a preorder traversal, together with information aboud the tree structure.

I guess (this needs to be checked) that two bits indicating if a node has left and right children is enough to reconstruct correctly while reading back.