Continue on Recursion
![]() |
| Tree |
After reading week, we continued the
lectures about recursion, however, the lecture focused on a different class
named BTNode, a generic Tree design. In my opinion, Tree enables us to learn
the recursion method more visualizable. We can trace the steps in a specific
diagram.
![]() |
| Initialize of the BTNode |
Compared with the lectures before
reading week, the codes we wrote in this week’s lecture seem to be more
complicated. The reason is that parents and leaves should not only be run, but
also be evaluated whether it is valid and the codes should be calculated in a
specific order. All these requirements needs more specific methods to be written
in one class.
![]() |
| evaluate method |
In evaluate method, the return
result is the value after being calculated by the int and str provided in the
tree. And the simplest situation is when the node is a leaf, which would
involve another method in the class. However, the recursion steps are similar
with before. But the calculation in the recursion steps would make us confused
and lost in the position of tracing steps.



No comments:
Post a Comment