6.7

Assignment 15

home work!

Programming Language ISL+

Due Date Thurs 3/16 at 11:59pm

Possible Points 64

Purpose To design functions that process trees.

Graded Exercises

(define-struct leaf [])
(define-struct node [data left right])
; A [Tree X] is one of:
; - (make-leaf)
; - (make-node X [Tree X] [Tree X])
 
 
(define-struct person [name yob])
; A Person is a (make-person String Number)
; - where name is the person's name
; - and yob is their year of birth
 
; An FT is a [Tree Person] and represents a family tree, with the youngest person at the root.

Exercise 1 Design the function ft-valid? that takes a [Tree Person] and determines if every persons’ ancestors were born before that person.

Exercise 2 Design the function namesake? that takes in an FT and determines if anyone has one of their ancestors’ names.

Exercise 3 Design mirror which takes any tree and flips all of its right/left branches all the way down the tree.

Exercise 4 Design names which takes an FT and returns a list of all of the names of the people in the tree.

Exercise 5 Abstract mirror and names and use this abstraction to redefine mirror and names (leave the old versions commented out).

Exercise 6 Explain in a comment why this abstraction could not be used to define ft-valid? or namesake?.