There are n students (assume student names are unique) in a college. Each student has list of college friends. Count of college friends of one student may vary with other student.
Propose an efficient data structure if (a) n is known (b) if n is unknown, such that following queries can be answered efficiently.
(i) Display list of all college friends of ABC (user entered student name).
(ii) Display list of all students to whom ABC is one of the friend.
(iii) Display list of students who are friend to ABC as well as XYZ (another student name entered by user).
(iv) Display name of student (s) who has maximum friends.
(v) Display name of students (s) who has maximum common friends.
(vi) Due to some reason one student left the college. Delete his name from the list of students as well as delete his name from all students friend list.
(vii) Some students may join the college late and make friends after words. Add these students record into list of students along with their list of friends. Further, add their names into the friend lists of other students whom newly joined student is a friend.