Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem 3 (Textbook Exercise 9.3-5). The median of a set S of n elements is the n/2 smallest element in S. Suppose that you are
Problem 3 (Textbook Exercise 9.3-5). The median of a set S of n elements is the n/2 smallest element in S. Suppose that you are given a deterministic algorithm for finding the median of S (stored in an array) in O(n) worst-case time. Using this algorithm as a black box, design another deterministic algorithm for solving the k-selection problem (for any k[1,n] ) in O(n) worst-case time. Problem 4. Let S be a set of n integers, and k1,k2 arbitrary integers satisfying 1k1k2n. Suppose that S is given in an array. Give an O(n) expected time algorithm to report all the integers whose ranks in S are in the range [k1,k2]. Recall that the rank of an integer v in S equals the number of integers in S that are at most v. Problem 5. Let S be a set of n integers given in an array. Describe a deterministic algorithm to find the 100 largest integers in S in O(n) worst-case time
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