CS 1101: Practice problems on Trees


Continue with the ancestor trees (people refer to mother/father) from class.

  1. Write a function count-name that consumes a name and a family tree and produces the number of people in the family that have the given name.

  2. Write a function mother-known? that consumes a name and a family tree and produces a boolean indicating whether the named person's mother is known (is a person, rather than 'unknown).

  3. Write a function update-mother that consumes a person's name, person-struct for their mother, and a family tree and returns a family tree in which the named person has the given person structure as their mother (you may assume that the person's mother was unknown in the original tree if you wish).

  4. Write a function add-mother that consumes a person's name, name, birth year and eye color for that person's mother and a family tree and produces a family tree in which the named person has a mother with the given data. Use update-mother as a helper.