CS 1101: Lab 5 (Complex Trees)

Lab Motivation and Goals

To make sure you can


A company maintains several pieces of information about its employees: their name, hourly salary, the names of projects they work on (could be several, like database, web, service), and which (other) employees they supervise. A person may work on different projects than his or her boss.

  1. Develop a data definition and two examples of data for company employee hierarchies. The hierarchy should start with a single person (the boss). (The data for who each person supervises should be other employees, not just those employees' names.)

  2. Provide the template for an employee hierarchy.

  3. Write a function everyone-busy? that consumes an employee hierarchy and produces a boolean indicating whether every person in the company is working on at least one project.

  4. Write a function on-project that consumes the name of a project and an employee hierarchy and produces a list of names of people who work on the named project.

    Everyone should be able to finish up to this point

  5. Write a function raise-by-project that consumes a project name, number (percentage), and employee hierarchy and produces an employee hierarchy in which every person on the named project gets a raise of the given percentage.

  6. Write a function base-payroll that consumes an employee hierarchy and produces a number. The number is the total base payroll for the company (each person's hourly wage times 40 hours per week).

  7. Write a function entry-hire that consumes a name, salary, project, name of an existing employee (boss of the new person) and an employee hierarchy and produces an employee hierarchy. In the returned hierarchy, the named employee has an additional employee, who has the name, salary, and project given as inputs.

  8. Write a function find-employee that consumes a name and an employee-hierarchy and produces either an employee hierarchy or false (if there is no employee with that name in the hierarchy). The produced hierarchy should be the portion of the original hierarchy that has the named person as the boss.

    [Note: this one is a bit tricky. You might find it easier to do the remaining problems assuming that you had finished this one, then come back and write find-employee. You could test the others before finishing this by making a really simple version of find-employee that just produces its input without searching in it--as if you were always searching for the boss. This would at least let your other programs run while you think about this one.]

  9. Use find-employee to write a function works-under that consumes a name and an employee hierarchy and produces the names of all people who work under the named person. Assume the named person is in the hierarchy.

  10. Using functions you already wrote for this assignment, write a function more-costly that consumes the names of two employees and an employee hierarchy and produces the given name whose group (person and all those under him or her) costs more money in payroll. Assume both named people are in the hierarchy.

Back to the Labs page