Question
In java write code to find the k th largest element in the array A by a deterministic Selection and print the 1 st ,
In java write code to find the kth largest element in the array A by a deterministic Selection and print the 1st, 3rd, 5th, 10th, 13th, 15th largest elements. Here is the pseduo-code I need it turned into real code:
Select(A,i,n)
1 if (n = 1) 2 then return A 3 Split the items into bn/5c groups 5 (and one more group). Call these groups G1,G2,...,Gbn/5c 4 Find the median mi of each Gi 5 Recursively compute the median of medians, p = Select({m1,...,mbn/5c},bn/10c,bn/5c) 6 L = {x A : x p} H = {x A : x > p} 7 if i |L| 8 then Select(L,i,|L|) 9 else Select(H,i|L|,|H|)
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