As a class, our first introduction to Trees was Diane's very amusing classroom activity. In said activity, each student became a node in a tree, with the root at the back of the class "looking over his domain". As the tree moved through the class the more vocal nodes monopolized possible children while the quieter nodes remained childless and eventually became leaves as all possible nodes were claimed.
After we created this abstract data structure, Diane had us apply recursion subtly. This wasn't presented as an exercise where we had to use recursion, however a recursive height calculating algorithm is a beautiful solution to figuring out the depth of a tree. Even though this was done at a point where all students should be familiar with a simple recursive algorithm, I found many of my classmates were confused as to the implementation of this algorithm.
For example, the exact implementation of finding the height of a tree is to add one to the largest height amongst the children of said node. I was an interior node in the class wide tree, and one of my children had a height of 6. So I turned to my parent node and told him that I had height 7, I continued to watch him and dumbfounded I hear him tell his parent that he has height 7. However the parent had heard what I had said and was actually paying attention in class and quickly corrected him, seconds before I would have.
No comments:
Post a Comment