Sunday, 5 April 2015

Revisit an earlier SLOG

I have revisited my slog about Tree, and I agree my analysis  about Tree. To begin with, I understand tree is constructed by multiple of nodes, and in order to traverse, we have to understand the use of recursion first. To start with, the most basic example of recursion is factorial. The fundamental concept of factorial is n(n-1)(n-2)(n-3)......*2*1. Similarly, traversing each children of each nodes is like the process of factorial. Therefore, we can apply recursion in the programming of Tree. In addition, there also different kinds of tree, such as Binary search Tree, which makes sorting and searching faster because it only has left children and right children, and the left children is always smaller than its parent node while the right children is greater. In conclusion, the concept of Tree is pretty straight forward, but the only trick thing is to understand the process of recursion. Firstly, you have to implement the base case of the stop of the recursion, and then you need to write the code for the first few step. And finally, you just need to apply recursion over it. Eventually, Tree becomes easier after you fully understand the concept of recursion.

No comments:

Post a Comment