First we need to create a database which maintains all the students at UNI
Then we will create a social networking application like facebook that will maintain a list of friends of each student.
A student at UNI should have at least the following parameters: (Please note that you may add additional parameters of your choice for each student if it helps you in any way)
ID: int (note that only IDs are unique for each student)
First Name: string
Last Name: string
year: int (values are 1, 2, 3, or 4 depending upon if a student is first, second, third, or final year student)
Registered Courses In Current Semester: string array
Completed Courses: string array
friends: Student * (this field is of type Student pointer which points to the object of type Student)
next: Student* (this pointer will point to the next student in the list)
You should create pointer, say UNIDatabase, as the head of the database which points to the linked list.
UNIStudent * UNIDatabase = NULL; //this pointer is the head of the linked list. Don’t call it head.
You should provide functions to support the following operations:
1. Add a new student in the list (take input from user, all the fields and add a new student)
2. Delete a student from the list (based on student’s ID). Notice that deleting a student should delete all the friends of that student as well.
3. Add a student as a friend of a student (by student ID). You should ask two IDs as input from the user, ID1 and ID2, and then add student with ID2 as the friend of the student with ID1.
4. Delete a student as a friend of a student (by student ID). You should ask two IDs as input from the user, ID1 and ID2, and then delete student with ID2 from the friends of the student of ID1.
5. Print all the students in the list.
6. Delete all the friends of a particular student (by student ID).
7. Delete all the students from the list. This includes deleting all the friends of each student as well.
8. Print all the students from the list with gpa equal to n.
9. Print all the students from the list with first name equal to f.
10. Print all the students from the list with last name equal to n.
11. Print all the students of a particular college.
12. Print all the students of a particular major.
13. Find and print if a student is in the list (find by first name, find by last name, find by ID).
14. Find if a student is a friend of another student.
15. Find and print all the students who added a particular student ‘s’ as their friends.
16. Print all the students who have n friends (n could be 0, 1, 2, 3, …).
17. Print all the friends of a particular student (by student ID).
18. Print all the students who have maximum friends.
19. Print the list of most popular students. It means all the students whom maximum students have added as their friends.
20. Find if a student’s friend has also added this student as his friend.
The following diagram shows how the linked list should look like. Please note about the following diagram of linked list:
1) UNIDatabase is the name of the head of the linked list that contains all the students at UNI(shown as the first row of list).
2) Each Node represents a student which contains all the fields mentioned above including:
a) one pointer “next” that points to the next student in the list (shown by an arrow on
the right hand side of each node).
b) one pointer “friends” (shown by an arrow in the bottom of each node) which
points to the friend of top most student.
3) In this diagram, each node only mentions id of the student. However, it also contains other fields as mentioned above, but that is not shown in the diagram to keep it simple.
4) The vertical list corresponding to each node is the list of friends of the top most student. For example, student with id=3 has only two friends (id=2, and id=1). Similarly, student with id=5 has no friend. Note that a student ‘x’ can call student ‘y’ to be his/her friend, but student y may not want to add ‘x’ in his/her friend’s list. For example, student with id=9 has student with id=1 as his/her friend, but student with id=1 did not add student with id=9 in his/her friend’s list.