Here in CSC148 throughout week 7, we were introduced to the abstract data type of the binary tree. Building upon the generic Tree ADT that we were introduced to earlier in the semester, the binary tree has the special characteristic of having up to two child nodes designated "left" and "right". Personally, one of the really radical things about the binary tree (and by extension, the tree) is how the class is kind of "recursive" simply in its existence. When I say that, I mean that the tree is essentially made up of a node that points to two smaller trees. In addition, the trees are stored through a class that keeps track of nodes, with internal nodes also keeping track of their children and their children's children. The root node of humongous trees with millions of children is an instance of the same class that each and every child node is also an instance of. If there was ever an ADT that was perfect for recursion, this is it.
As mind-boggling as recursion has a tendency to be at times, the class designed around recursion was just as mind-boggling as I expected. Going through the exercises in labs, I managed to gain a pretty solid grasp of what was going on, but the whole system of having trees contained inside of nodes of trees and having an entire tree represented in a single node was kind of a weird concept to wrap my head around. By the end of the lab, I had built-up the same relationship with the implementation of the binary tree as with the limit in calculus and particle-wave duality of electrons in physics: I could solve problems with them and I accepted that they existed and were valid, but the concepts didn't seem to fit quite right in my head. Hopefully, with time and more practice, I'll gain a stronger grasp of the concept of how a binary tree is implemented.
Binary trees do not have a recursive structure, because recursion is the process of repeating items in a self-similar way. By that I mean, a binary tree that is a root will be different than a binary tree that is the left child of the previous binary tree. It would be like saying that a list with a sublist has a recursive structure, because there is a list within a list. Which is not true, because the two lists are distinct and separate entities.
ReplyDelete