Create a hash table for students and another hash table for course.. For each record in the student table create a linklist that stores the list of all the course in which the particular student in enrolled. For each record in the course table create a linklist that stores the list of all the students enrolled in this course..
Space will be O(m n) m is the number of students and n is the number of courses Time will be.. a) Return all students in a list. O(m) b) Return all courses in a list. O(n) c) Return all courses in a list for a given student. O(n) d) Return all students in a list for a given course. O(m) let me know if it sounds good.. Sahil Garg Computer Engineering Delhi College of Engineering On Sun, Oct 30, 2011 at 1:17 AM, Aamir Khan <ak4u2...@gmail.com> wrote: > In a university, students can enroll in different courses. A student may > enroll for more than one course. Both students and courses can be > identified by IDs given to them. Design a data structure to store > students, courses, and the student-course relationships. You can use > arrays, lists, stacks, trees, graphs, etc. or come up with your own data > structures. Give the running times, in Big O notation, for the following > operations for your data structure and justify the answers: > > a) Return all students in a list. > b) Return all courses in a list. > c) Return all courses in a list for a given student. > d) Return all students in a list for a given course. > > > > > > Aamir Khan | 3rd Year | Computer Science & Engineering | IIT Roorkee > > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.