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
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