Question

I'm given a project in college to use trees(AVL tree, to be specific) and file handling(not very conversant with it). But I'm not able to relate the two. I only know that files can be used to store data. But in what way can trees and file handling be connected? I know how to implement trees but how to store it as such in files?

Était-ce utile?

La solution

If you know any two of the three tree traversals (preorder, inorder, postorder), you can construct the AVL tree. Since AVL tree is a BST, inorder is known. So, store any of postorder or preorder in the file. From that, you can construct the whole tree.

See about tree-traversal.

And also how to construct tree from inorder and preorder traversals.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top