Question
Problem 1 (K th quantiles) Let S = {s1, s2, . . . , sn} be a set of distinct real numbers. The K th
Problem 1 (K th quantiles)
Let S = {s1, s2, . . . , sn} be a set of distinct real numbers. The K th quantiles of S is a subset of exactly K 1 numbers s 0 1 < s0 2 , . . . , s0 K1 such that the cardinality of
Sj = {s S | sj1 < s sj}
are the same. Design a divide and conquer algorithm to find the K th quantiles of a given set S of N numbers. You may assume that K is a power of 2 and that it is possible to partition S into K equal sets. Your input is the set S, and the value K. S is not sorted.
Examples:
For S = {2, 4, 1, 6, 0, 9}, K = 3 your design should output {1, 4}.
For S = {1, 2, 4, 1, 3, 0, 18, 2}, K = 2 your design should output {1} ((i.e.: the 2 th quantile is the median)).
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