The topic of the week was Trees, which are an abstract data type.
Let me break it down for you. A Tree is a set of connected nodes
containing values. A root is a node with no parent, there is exactly
one root per tree, and every other node has exactly one parent. A
leaf is a node with no children. Height is the longest path in a
tree, and arity, or branching factor, is the maximum number of
children on any node in a tree.
Tree traversal is a difficult concept to write about because it
requires a visual understanding.
This video, posted on piazza by a
helpful classmate, made me understand traversal so easily. To recap:
Pre-order: root, pre-order left subtree, pre-order right subtree.
In-order: in-order left subtree, root, in-order right subtree.
Post-order: post-order left subtree, post-order right subtree,
root.
We also went over the implementation, methods, and attributes
within the Tree ADT. It will be interesting to write programs
utilizing Trees in the coming weeks.
In Lab 5 we looked at functions written with comprehensions,
including Python built-ins zip and filter. The goal was to rewrite
these functions without comprehensions, so in other words to manually
expand them and as a result better understand how the comprehensions
work. My lab partner was absent, but even with working alone I
didn't find it too difficult. All of the tools shown in this lab
will definitely be helpful in the future as they make code cleaner
and more efficient.
A1 was due this week, which I handed in on time,
woo! While it
took longer, I'm glad I worked alone because it ensured that I
understood all of the code, and I know that will help with future
tests. I would have liked to spend more time finding the optimal
solution for four stools, and I'm confident I could have completed
the bonus portion, but in the middle of midterm madness I had to
prioritize and chose not to do those things.
Reading week time! I hope to get work done, but we all know that's
not going to happen.