Starting from:
$30

$24

Exercise #3 Solution

In this exercise you will be practicing working with double linked lists (dll). You are required to write two functions.




a function called reverse_merge that takes two double linked lists as its input parameters. The first linked list contains the surname of Marzieh’s students in CSCA48 sorted ascendingly and the second contains Nick’s students’ surname for the same course sorted in a descending order. In order to allocate a room for term test 1, we need to merge these two lists to one list that contains all the student’s surname sorted ascendingly. Therefore, your function should return a DLL containing all the surnames.



A function called allocate_room that takes four parameters; a dll containing students’ surnames, a string representing room name and number, an int representing the capacity of the room and an int representing the index of the node that contains the surname of the first person that is assigned to this room. Your job is to return a string that shows the two first letters of the surnames of the first and last person that should attend the given room. Here is an example:



allocate_room(csca48_list, “SW319”, 80, 150) SW319 JU-MO



What we know/ don’t know




We don’t know how many students registered for each class therefore you should expect that the length of these two lists are not the same.



We know that both Marzieh and Nick implemented their DLLs with a dummy head and tail.



csca48_list is also a dll implemented with a dummy head and tail.



We found that there are a few students who registered for both the lectures therefore their surnames are in two lists. Obviously the resulting list should not repeat their names.1



It is absolutely fine if the capacity of the room is n and we only have m students, where m < n








More products