Another week has come and gone. I can't believe were practically half-way through the semester already. But nonetheless heres a brief preamble of the material that was covered in lectures. The topic of discussion this week was trees. Trees are basically hierarchal data structures, similar to the notion of a family tree. In the case of a binary tree, every node has exactly one parent, except for the root which has no parent. Furthermore, each parent node has no more than two children.
As suggested by the title, trees are a recursive data structure, so it shouldn't be surprising that many recursive routines can be implemmented. For example, questions like 'how many nodes are in this tree' or 'whats the length of the longest path of this tree' can be answered by implementing recursive code. At first, I found the implementation of these recursive algorithms to be quite confusing. But after throughly reading over the lecture notes, and the material covered at the following link http://openbookproject.net/thinkcs/python/english3e/trees.html, I have vastly improved my comprehension.
No comments:
Post a Comment