Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started