Recursive Data Structures

1. Why Recursive Data Structures?

In this essay, we are going to look at recursive algorithms, and how sometimes, we can organize an algorithm so that it resembles the data structure it manipulates, and organize a data structure so that it resembles the algorithms that manipulate it.

When algorithms and the data structures they manipulate are isomorphic, the code we write is easier to understand for exactly the same reason that code like template strings and regular expressions are easy to understand: The code resembles the data it consumes or produces.

We'll finish up by observing that we also can employ optimizations that are only possible when algorithms and the data structures they manipulate are isomorphic.

Here we go.


Source: Reg Braithwaite, https://raganwald.com/2016/12/27/recursive-data-structures.html
Creative Commons License This work is licensed under a Creative Commons Attribution-ShareAlike 2.0 License.