Question: How do I solve this in O(nlogn) time? Question 4. (40 points) Let S denote the set of n employees in a company. For convenience,

 How do I solve this in O(nlogn) time? Question 4. (40

How do I solve this in O(nlogn) time?

Question 4. (40 points) Let S denote the set of n employees in a company. For convenience, we assume the n employees are numbered using the integers 1 to n. Let s[i] denote the salary of employee i, and let p[i] denote the job performance of employee i (i.e., how good they are at their job, with a larger p[i] indicating better performance). Asssume that both salaries s[i] and job performance measures p[i] are large integers (much larger than n ) and that they are distinct (i.e., no two salaries are same, no two performance values are same). The arrays p and s are given in no particular order (i.e., neither is given sorted). 1. (20 points) Give an efficient algorithm that outputs every employee i for whom there is at least one other employee who does a better job at a lower pay. That is, employee i is in the output if and only if there is at least one other employee j that has s[j]p[i]. Analyze and state, as a function of n, the time complexity of your algorithm

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 Databases Questions!