Slog week 11 | Reflections..Reflections
Slog week 8 | Trees!
This week (and a bit last week) we focused on the tree ADT. I was excited to learn a new ADT but reluctant at the same time. Mainly because it takes me so long to get my head around a particular ADT. In order to fully apply one in exercises you literally have to change the way you think! This was even more complicated because of the fact that trees are a recursive ADT and use the concept of recursion extensively. I don’t have a full grasp on recursion yet (mainly due to lack of experience) and that it why trees seemed scary at first.
A tree is composed of many nodes. It is made up of parent nodes (aka roots), children nodes (leaves), or both! We call the arrows in between them edges.
A tree has many properties such as arity (or the branching factor) which determines how many children is the parent node allowed to have, depth which measures the amount of nested nodes in a tree, and height which is basically depth  + 1.
Prof Danny even said that a linked list is actually a specialized type of tree which actually now makes sense. It is always nice when two separate concepts reunite into one definition.
In this Slog, I shall be reflecting on my week 8 Slog (quoted above) about the tree Abstract Data Type or ADT. Trees in particular are an interesting topic to reflect on because my comprehension of them was completely changed when doing our puzzle assignment.
The puzzle assignment I just mentioned was a great practice for this subject because it shows how the use of trees is extremely versatile and highly efficient depending on the case or algorithm you implement it in. In this assignment, we had to search for a particular puzzle configuration (a solved puzzle configuration, basically). This task seems easy enough at first, but it is actually anything but easy. The search functions in this assignment is what made me fascinated with the tree ADT. Â Our search had to start with an initial Puzzle node (a tree node that contains a puzzle configuration) and then that node refers to other extension nodes ( an extension is defined as a legal move). A diagram below is a good visualization of the situation
As we can notice, these aren’t ordinary tree nodes. They in fact contain two references one to the parent node, and another to the extension. This special type of tree is closely related to another ADT structure;  the linked list. This is why my view of trees ADT was changed. At this point, I realized that the ADT structure is actually not set in stone. And that as programmers, we are allowed to play with it and tailor it according to the needs of our program.For example,  with this structure I can implement an algorithm that searches hundreds (if not thousands)  of extensions and I can even tailor that algorithm to search the children first before moving on to the next level of children ( breadth-first search). This is all thanks to this structure which really resolves a lot of the logic problems that would go through implementing a search algorithm such as this. Â
Overall, my impression of trees was changed because as I just mentioned, I realized that the overall form can be changed as long as you keep the references correct and so on. Also, trees are now a lot easier to think about and I seem to think they are a lot less “scary” than what I thought in week 8. This is of course due to lots of practice and hard work. I intend to keep practicing this concept because I’m genuinely curious as to what other applications I can apply this structure to.
FUN FACT: multiple instances of trees is called a forest! Cool.













