A standard approach is to define a "node" struct that contains your data field, and left and right pointers to other nodes. One can build a tree out of nodes. You should encapsulate your tree data in a class and provide insert, delete, traverse, etc. functions. If you ensure left children are "less than" the current node and right children are greater then you have a Binary Search Tree.
Why does the C++ STL not provide any "tree" containers?
Why does the C++ STL not provide any "tree" containers, and what's the best thing to use instead?
I want to store a hierarchy of objects as a tree, rather than use a tree as a performance enhancement...
Follow
1
Add comment
More
Report
1 Expert Answer
Still looking for help? Get the right answer, fast.
Ask a question for free
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Find an Online Tutor Now
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.