Project 4 Explanation of Adding People and Friendships This is a quick walk-through of how memory changes as we add new people and friendships to Facebook. Consider a people.txt file that only contains the following: person alice rhodes person bob rhodes person carla sewanee friend alice bob friend alice carla (This is a simplified version of the sample people.txt file.) The steps in the walk-through below are illustrated in the accompanying diagram. The parts of the diagram in red show what is new about each step. Step (1): Start of the program. We haven't read anything from people.txt yet. all_people is empty. There is nothing on the stack. Step (2): We read from people.txt to add a person named alice who goes to rhodes. We allocate a person on the heap (with new) and set that person's name to alice and school to rhodes. Alice starts out with no friends (everyone begins with no friends). We push_back a pointer to this dynamically-allocated person into all_people. (Note that because alice was allocated on the heap, we *only have* a pointer to alice. We don't have an actual variable that stores alice's information, only a pointer that points to the information. So pushing_back a pointer to alice is all we can do anyway.) Step (3): We read from people.txt to add a person named bob who goes to rhodes. We allocate a person on the stack and set that person's name and school, then push_back a pointer to Bob into all_people. Step (4): We add carla to the database. Step (5): We read from people.txt to make alice and bob friends. In other words, we need to update alice's list of friends to add bob, and update bob's list of friends to add alice. We do this with a linear search over all_people to find the appropriate pointers to alice and bob. Once we find the pointer to alice, we get alice's friends and push_back a pointer to bob. Then with the pointer to bob, we get bob's friends and push_back a pointer to alice. Step (6): We repeat the same idea to make alice friends with carla. Note that at the end of all of this, alice has two friends (bob and carla), but bob and carla each have only one friend (alice).