Question: (10 points) Describe an O(n) time algorithm for the following problem: - Given a set S of n distinct numbers in an arbitrary order and

 (10 points) Describe an O(n) time algorithm for the following problem:

(10 points) Describe an O(n) time algorithm for the following problem: - Given a set S of n distinct numbers in an arbitrary order and a positive integer k(kn), find k numbers in S that are closest to the median of S. Consider S={5.2,4.7,1.0,5.0,4.9,9.0,7.0,4.8,8.0} and k=4. Then, 5.0 is the median of S, and 4.8,4.9,5.0,5.2 are the 4 numbers that are closest to 5.0

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!