CS 1101 - A-term 07

Homework 12 - Developing a Social Networking Site

Due: Tuesday, October 9 at 11:59pm


Assignment Goals

To make sure you can create and write programs with linked data structures and structure assignment.

Remember to follow the Expectations on Homework when preparing your solutions.


The Assignment

You are asked by a web startup to develop a social networking site. The site is meant to keep track of people and their friends. Also, several functions are necessary to manipulate and query the social network.
  1. Provide a data definition for a person. Each person has a name and a list of friends (persons).

  2. Define a variable for a social network called network that will hold a list of persons (it should initially be empty).

  3. Write a function create-person that consumes a person's name and returns a new person with the given name (and no friends). The new person should also be added to the network. You may assume the named person does not already exist in the network.

  4. Use create-person to populate the social network network with at least 5 different persons. (You may wish to "define" these new persons so you can refer to them in later exercises.)

  5. Write a function connect-friends that consumes two persons, and makes them each a friend of the other. (A person A is a friend of person B if person A's friend list contains B and vice versa.) You may assume that the given persons are not already friends. Your function should return void.

  6. Use connect-friends to establish at least 5 friend pairs in network.

  7. Write a function find-person that consumes the name of a person and returns that person if it exists in network, or returns the string "not found" otherwise. Provide test cases for this function and any helpers you write.

  8. Write a function most-social that consumes nothing and returns the person with the most friends (resolve ties arbitrarily). Return "empty network" if network doesn't contain any persons. You may use the Scheme built-in function length.

What to Turn In

Using web-based turnin, turn in a single file hw12.scm containing all code and documentation for this assignment. Please make sure both partners' names and wpi login names are listed in a comment at the top of the file.