Question: Please use C++ or Java... (I'd prefer C++) Part A. Write a function called Quick_select to find the kth least element on a given array.

 Please use C++ or Java... (I'd prefer C++) Part A. Write

Please use C++ or Java... (I'd prefer C++)

Part A. Write a function called Quick_select to find the kth least element on a given array. (The average running time of your algorithm should be O(n)) (Hint: Use partitioning algorithm) Request the user to enter a positive integer, and call it n. 2. 1. Generate n random integers between 100 to 100 and save them in array a. (You can use randi function in MATLAB) 3. Print the generated array. Request the user to enter a number between 1 to n (as the kth least element). 5. 4. Call your function to find and print the kth least element. Part B Explain an algorithm to return the max k numbers from an unsorted array. (The average running time of your algorithm should be O(n) (Hint: You could modify your Quick_select algorithm to solve this question.)

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!