Tuesday, February 18, 2014

Week 6: recursive data structures


In this week’s material, we ventured on to the topic of recursive structures with a focus on binary trees (aka the ‘TreeList” class). I thought this week’s lecture was particularly interesting, given that this was my first interaction with ADT with a recursive spin to it.

I found the idea of binary tree’s intuitive and appealing from a functional perspective. I have to admit, it took me a while to wrap my head around the concept, but once I did, I could immediately see the functional aspects of using recursive data structures over traditional methods of organization (i.e. for searching applications).

Binary Tree: a tree made of 0s and 1s?
To my understanding, binary trees are composed of ‘nodes’ and ‘leaves’, where nodes that have children are referred to as internal nodes, and nodes with no children referred to as leaves. The height of a tree is defined as the maximum path length from a root to a leaf. The arity of a tree refers the maximum number of children for any node, which in the case of a binary tree, is 2.

Final Thoughts and Reflections

On a side note, shortly after class, I had a brief discussion with a classmate (who’s been programming in C ++ since he was 13), who told me that when he first learned about recursive data structures, his instructor had used the example of pointers referring to memory address rather than nested lists to explain recursive data structures. This got me thinking some more about recursive ADTs, and made me realize that a binary tree could have just as easily been implemented using pointers pointed at unique memory addresses containing ‘child objects’ rather than using something like a “TreeList”.

No comments:

Post a Comment