Trees in programming are a data structure that can take on many forms. They involve linking nodes to each other all originating from a root. A node is one element of the tree. A root is the beginning node. A leaf is a node with no children(no nodes on lower level). Binary trees are trees in which every node can have up to two nodes attached to it.
Traversing is parsing throughout he data in a tree. There are three ways in which you can traverse the data in a tree; pre-order traversal, in-order traversal, and post-order traversal. Pre-order traversal is when you start with the root then the left subtree then the right. In-order is when you start with the left then the root then the right subtree. Post-order is when you start with the left subtree, then the right, and finally the root.
To end this discussion I just wanted to state that trees are a very useful recursive data structure and they did not pose many difficulties.
No comments:
Post a Comment