


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Exam Computer science notes with comments and answer
Typology: Transcriptions
1 / 4
This page cannot be seen from the preview
Don't miss anything!



(c) The following pseudocode subroutine merges two sorted lists of equal or unequal lengths. It is called with the two lists shown in the main program. NOTE: Given that list1 = [1, 2, 5, 10], then list1[1:] = [2, 5, 10]. That is, it returns a sublist starting with list1[1].
--Same as the comment above but you switch the numbers--- ###Condition for the if statement### If the first position of list2 is less than list 1 first index then Return (list 2’s first index and the truncated version (remove first index) of list 2 and full of list 1) Then since it calls the function merge inside the function merge (recursive function) You then take your return output and start from the begging of the function###
(iii) What parameters will be passed to the subroutine the first, second and third times that a recursive call is made? [3] First time: [3,7,9], [2, 5, 10] Second time: [7,9], [5,10] Third time: [7,9], [10]