Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started