6.6

Assignment 14

home work!

Programming Language ISL

Due Date Monday 11/5 at 9pm

Purpose To process tree-structured data.

Expectations
  • You should submit a single .rkt file containing your responses to all exercises via the Handin Server. We accept NO email submissions.

  • You are only allowed to use the language specified at the top of this page: failure to do so will result in a 0.

  • All steps of the design recipe are required unless otherwise specified. However, at this point we expect you are familar with the [List-of X] data definition and do not require it or its template.

  • You are expected to use pre-defined abstractions when stated and/or when appropriate.

(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 family-member [name yob])
; A FamilyMember is a (make-family-member String Number)
; - where name is the family member's name
; - and yob is their year of birth
 
; An FT is a [Tree FamilyMember] and represents a family tree, with the youngest
; family member at the root.

Exercise 1 Provide examples and design the template for an FT.

Exercise 2 Design a function which returns the list of everyone’s age in a FT. Assume everyone is still alive and that everyone was born at midnight on January 1st.

Exercise 3 Design a function which produces the maximum age of any family member in a given FT. When given a leaf structure your function should produce 0. You may make the same assumptions as you did in exercise 2.

Exercise 4 Design a function which, given an FT, produces the number of generations shown by the tree. So a tree with a single family member in it contains only 1 generation, but a tree that shows a family member and their parents contains 2 generations, and so on.

Exercise 5 Design a function which determines if anyone has been named after their ancestor in a FT.