This preview shows page 1. Sign up to view the full content.
Unformatted text preview: Mutual recursion is what makes it possible to explore the twodimensional tree data structure fully. In particular, note that reaching the base case in forestmap does not mean that the entire tree has been visited! It means merely that one group of sibling nodes has been visited (a “horizontal” base case), or that a node has no children (a “vertical” base case). The entire tree has been seen when every child of the root node has been completed. Note that we use cons , car , and cdr when manipulating a forest, but we use maketree , datum , and children when manipulating a tree. Some students make the mistake of thinking that data abstraction means “always say datum instead of car ”! But that defeats the purpose of using different selectors and constructors for different data types. • Deep lists Trees are our first twodimensional data structure. But there’s a sense in which any list that has lists as elements is also twodimensional, and can be viewed as a kind of tree. We’ll use the nameelements is also twodimensional, and can be viewed as a kind of tree....
View
Full
Document
This note was uploaded on 02/17/2010 for the course COMPUTER S 26275 taught by Professor Harvey,b during the Spring '10 term at University of California, Berkeley.
 Spring '10
 Harvey,B
 Recursion

Click to edit the document details