Question: 3. (15 pts) Suppose that you are given a set of locks and keys, each of which is labelled with a tag number. Suppose also

3. (15 pts) Suppose that you are given a set of locks and keys, each of which is labelled with a tag number. Suppose also that each lock can be opened only with the key labelled with the same tag number and no two locks have the same tag number. Design an algorithm that finds the number of locks that can be opened with the given keys. More precisely, you may assume that the input of your algorithm is two integer arrays L and K of equal length that store the tag numbers of the given locks and keys, respectively. Your algorithm will output an integer m that represents the number of tag numbers in array L that also appear in array K. To receive full credit the running time of your algorithm must be O(n lg n), where n is the length of both array L and array K
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
