This week the topic of lectures was all about trees. Trees are a data structure in python that work recursively when going through them. Their structure is very much like trees in real life, except upside down, as they have a root that has leaves or nodes sprouting from it who themselves can be roots that can leaves, and this can continue infinitely. With this visualization of trees I saw the inherent recursive structure to trees, as to implement any actions on trees you needed create a base case for a simple tree with one root and leaves and then implement that function recursively for leaves that are roots themselves. We looked at some examples of functions that traversed trees, such as three ordering functions that order the values of each node in the tree in preorder, inorder, or postorder, and all three of these functions worked just as I suspected, recursively.
I did not spend too much time analyzing class materials this week as the first assignment was due on Thursday and while I got caught up trying to finish assignments for other classes I was able to do most of Assignment 1 with my partner, not having enough time to implement an algorithm for a four stools Tower of Hanoi game, but we did implement it on our time later in the week for practice.
Until next week,
Maxim Isakov
No comments:
Post a Comment