Question: The following code computes the intersection ( the number of elements in common ) of two arrays. It assumes that neither array has duplicates. It
The following code computes the intersection the number of elements in common of two
arrays. It assumes that neither array has duplicates. It computes the intersection by sorting
one array array b and then iterating through array a checking via binary search if each
value is in What is its runtime?
int intersectionint a int b
mergesortb;
int intersect ;
for int : a
if binarySearchb
intersect;
return intersect;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
