Question: I prefer java application A.Write a function called Quick_selectto find the kthleast elementon a given array. (The average running time of your algorithm should be

I prefer java application

A.Write a function called Quick_selectto find the kthleast elementon a given array.

(The average running time of your algorithm should be O(n))(Hint: Usepartitioning algorithm)

1.Request the user to enter a positive integer, and call it n.

2.Generate nrandom integers between -100to100and save them in array a. (You can use randi function in MATLAB)

3.Print the generated array

.4.Request the user to enter a number between 1to n (as the kthleast element).

5.Call your function to find and printthe kthleast element.Part B.Explain an algorithm to return the max knumbers from an unsortedarray.

(The average running time of your algorithm should be O(n))(Hint: You could modify your Quick_selectalgorithm 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!