Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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,

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

How does selection differ from recruitment ?

Answered: 1 week ago