Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hi! We are asked to implement Quick Select and Median Finding in C program. I have made the code to solve this problem in https://pastebin.com/kwTP6NR
Hi! We are asked to implement Quick Select and Median Finding in C program.
I have made the code to solve this problem in https://pastebin.com/kwTP6NR
I'm missing the median_of_medians function and I have to fix the main() method since I'm not sure if I used the correct values. Please help me fix it so that it follows the correct input and output! Thank you
Problem Statement Following the problem definition at Module 10 the median of a list of integers is the middle element of a list when it is sorted (in increasing order). For example, 1 2 4 7 8 9 11 13 16 The median for this list is B, at position 5. 1 2 4 7 8 9 11 13 The median (lower median) for this list is 7, at position 4. An O(N)O(N) algorithm (we shall refer to as QUICK-SELECT) exists that can be used to find the median in a list of integers. QUICK-SELECT takes an integer array A, start and end indices (p and q, respectively), and a rank r integer. The rank of an integer in the list is its position in the sorted list For example, 1 2 4 7 8 9 11 13 the rank of 8 in the list above is 5. QUICK-SELECT returns the rthrth ranked integer in the list. To get the median of a list with NN elements, we can use QUICK-SELECT with rank [(N+1)/2]. An example pseudocode of QUICK-SELECT as given in our main reference (Cormen et al. Book) is given below: quick select (A, p, r, rank) if p == r return A[p] a = median partition (A, p, r) k = a - p + 1 if rank == k return A[g] else if rank
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