Question: 2. For the following problems, write pseudocode algorithms and state the worst-case running time (in terms of or O where appropriate). You will be graded

2. For the following problems, write pseudocode algorithms and state the worst-case running time (in terms of or O where appropriate). You will be graded on the efficiency of your solutions.

a)Given two lists of numbers A and B of lengths m and n respectively, return the intersection of the lists, i.e. all those numbers in A that also occur in B. You can assume that in any given list, the numbers are unique.

b)Given a sorted list of unique integers A[1...n], determine if an entry exists such that A[i] = i. If an entry exists, return the index, otherwise, return null. (Hint: You can do better than O(n). Think divide-and-conquer.)

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 Databases Questions!