Comp210: Principles of Computing and Programming
Fall 2004 -- Homework #5   


Read Sections 16-18 in the H.T.D.P. book.

All problems will require all (applicable) steps from the design recipe, including a template. Before you tackle the homework, remind yourself of our General Advice, Advice on Homeworks (in particular: staple and provide questions), and the Grading Guidelines.


A short homework assignment for this week due to the exam.

Remember: Contract, purpose, header and test cases are always required!

  1. (15 pts) Functions Processing Family Trees

    Using the following data definition of FamTree (see lecture for details):

  2. A FamTree is

    -- (make-unknown symbol)       
    -- (make-child symbol number famTree famTree), where the symbol represents a name, the first FamTree is the mother's family tree, the second FamTree is the father's side, and the number is the birthyear.

    write a function size-all: FamTree --> num , which counts the total number of nodes in a FamTree -- that is, the number of children and unknowns.

  3. (30 pts total) Functions Processing Lists of Lists.

    1. (10 pts) Imagine you want to model a school as a list of classes. Each class is a list of student' names. There may be multiple students with the same name. Write the data definitions for the structures to model this, including their resultant function templates.

    2. (10 pts) Write a function that will return true if a given student's name appears at least once in the school.

    3. (10 pts) Write a function that will return the number of times a given student's name appears in the school.

45 points total.

 


Last Revised Tuesday, 24-Aug-2004 13:49:22 CDT

©2004 Stephen Wong and Dung Nguyen