Question: Part B (5 points) We will now work on an algorithm that avoids the use of a hashtable (and thus any form of randomization) but

Part B (5 points) We will now work on an algorithm that avoids the use of a hashtable (and thus any form of randomization) but assume that the lists a1,..., ak are already sorted in ascending order. Write a function findCommonSorted(lst1, lst2) that takes in two sorted lists lst1 and lst2 and returns a sorted list of all common elements between them. Your algorithm must run in time (1+2) where 1,2 are the sizes of the two lists. As a hint, modify the merge algorithm. Note that the output list must be sorted in ascending order as well. def findCommonSorted(list1, list2): in python code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!