Frage

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?

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top