Question: Suppose you are given two sorted arrays a and b of the sizes m and n, respectively. A dominance of a over b is a
Suppose you are given two sorted arrays a and b of the sizes m and n, respectively. A "dominance" of a over b is a pair of indices (,)(i,j) such that a[i]>b[j]. Note that i is an index of array a and j must be an index of array b. the brute force algorithm is suboptimal. Design a Theta(n) algorithm to count the number of dominances. Do this by modifying the merge algorithm we studied as part of merge sort. Instead of merging the two sorted arrays, count the number of dominances. Please do not download any library or do not use any ready to use functions like sort... it is really important that my algorithm has to have Theta(n)time complexity
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
