Over last week's lectures, we talked about a new method called Trees, to be more precise: binary trees. The second tree above is a programming tree. Like a real tree, it also has roots, leaves, nodes, and so on. It also has heights, which the upper programming tree has a height of four. On a binary tree, we have those typical tree attributes as I states: nodes, leaves, paths... One node on a binary tree can only has up to two child nodes, and two is the max number, but it does not mean that for every node on a binary tree, there must be exactly two child nodes on it. And for the two child nodes, we can then call them left node and right node, which is so easy to understand.
Also, there are three different ways to examine a binary tree's data. Pre-order Traversal visits the parent node before it's child nodes from left to right; Post-order Traversal first visit all the child nodes from left to right and then visit the parent node; In-order Traversal visits all the left child nodes then left parent nodes, after that, right child nodes, and finally right parent nodes, note that In-order Traversal only occurs on a binary tree.
Tree is a difficult topic, and I need to spend more time on it.


没有评论:
发表评论