Trees are an interesting and useful concept in computer science.
While a general class Tree may be allowed to an unlimited number of children per node, a BINARY TREE is a tree with a branching factor 2 thus having a LEFT and RIGHT child.
Tree Traversal
Tree traversal is the act of visiting nodes so an operation may be completed at each node. There are three standard orders of visiting nodes. They are the following:
Binary Search Tree
A binary search tree is a tree with a branching factor 2 and has a special property:
"for every node, it's value is: - greater than all the values in the subtree
- less than all the values in the subtree"
It is important to note that a subtree of a binary search tree must also be a a binary search tree.
I find binary search trees quite interesting because of their special property. Binary search trees are interesting to set up if one is given a set of numbers and explained this property. I also found my recursion skills to be useful for tree code thus proving that it is quite important to practice this concept.
Overall, trees are an interesting topic in computer science and I look forward to learning more.
Until next time, climb that tree code!
Feel free to leave a comment.
While a general class Tree may be allowed to an unlimited number of children per node, a BINARY TREE is a tree with a branching factor 2 thus having a LEFT and RIGHT child.
Tree Traversal
Tree traversal is the act of visiting nodes so an operation may be completed at each node. There are three standard orders of visiting nodes. They are the following:
- PRE-ORDER traversal
- POST-ORDER traversal
- IN-ORDER traversal
Binary Search Tree
A binary search tree is a tree with a branching factor 2 and has a special property:
"for every node, it's value is: - greater than all the values in the subtree
- less than all the values in the subtree"
It is important to note that a subtree of a binary search tree must also be a a binary search tree.
I find binary search trees quite interesting because of their special property. Binary search trees are interesting to set up if one is given a set of numbers and explained this property. I also found my recursion skills to be useful for tree code thus proving that it is quite important to practice this concept.
Overall, trees are an interesting topic in computer science and I look forward to learning more.
Until next time, climb that tree code!
Feel free to leave a comment.
Recursion and trees go perfectly together because they are a recursive data structure: each tree is made up of smaller trees! More of this in CSC236.
ReplyDelete