Question: Note: This problem may be trickier and it is only worth 8 points. Design an algorithm that does the following: Given an input array A

Note: This problem may be trickier and it is only worth 8 points.
Design an algorithm that does the following: Given an input array A
of length n containing distinct positive integers, output an array B so that
B[i] contains the number of values j in {0,..., n 1} so that j > i and
3 A[j]> A[i].
Example: If the input is A =[6,2,4,1,7], the output would be B =
[2,3,1,1,0].
Your algorithm should run in time O(n log n). If it helps, you may assume
that n is a power of 2.
[We are expecting: Pseudocode, and a clear English description of what
your algorithm is doing. You do not need to justify the running time or the
correctness.]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!