So as week 7 came to an end, our lectures have only just grasped the basic concepts of binary trees.
The root of the tree is an object (a number, a string, anything) and is called a node. That node has the option of having children, in which the children are also nodes. If a node does not have children, the node is considered to be a leaf. Nodes that are not the root, the very first node in a tree, and have children are named internal nodes. This week, we were introduced to the concepts of binary trees. In binary trees, all inetrnal nodes have exactly two children and all nodes are not empty. We also learned about binary search trees, in which all nodes represent a number. The child to the left of the node (conveniently named the left subtree) is smaller than the node and, similarly, the child on the right of the node is larger than the node. For example, if we have the values 2, 4, and 6; if 4 is the node, then 2 would be the child to the left and 6 would be the child to the right. If 6 was the node instead, the 4 would be to the left of the 6 and the 2 would be to the left of the 4. Here is a small example of a Binary Search Tree:
This allows the programmer to easily search through nodes as it allows them to cut their search times exponentially as it is not necessary to go through all the values.
The concept is easy and simple to grasp and it seems, from the SLOGs I've read, no one else had any problems understanding it.
Oh and the strike is still on.
No comments:
Post a Comment