Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Selection ( A , k ) finds the k th smallest element of an array A . For example, if A = [ 3 ,

Selection (A,k) finds the k th smallest element of an array A. For example, if A=[3,11,20,6,7,38]
and k=3, then Selection (A,k) returns 7. Here is pseudocode for a divide and conquer algorithm for
Selection.
Note that in the following pseudocode I index A starting at 1, not 0.A[s,f] is the subarray of A
from index s to f inclusive of both s and f.
(a) What is the worst case runtime of this algorithm if ChoosePivot somehow always chooses the
pivot to be the median of the array, and the array is originally size n?
(b) Create and analyze a recurrence relation for the runtime of this algorithm if ChoosePivot somehow
always chooses the pivot to be the smallest element in the array, and the array is originally size
.
(c) Now consider the case that ChoosePivot chooses a pivot uniformly at random. Consider the
random variable xij, for ijAxijzizjkzizjkzizjkikji,j?
v. What is the probability ofzi and zj being compared ifwe are trying to find the kth order
statistic, and ikj?
vi. Use linearity of expectation, and properties of the expectation value of indicator random
variables to create an explicit expression involving sums that gives the average number of
comparisons done over the coruse of the algorithm.k?
iv. What is the probability ofzi and zj being compared ifwe are trying to find the kth order
statistic, and i,j?
v. What is the probability ofzi and zj being compared ifwe are trying to find the kth order
statistic, and ikj?
vi. Use linearity of expectation, and properties of the expectation value of indicator random
variables to create an explicit expression involving sums that gives the average number of
comparisons done over the coruse of the algorithm.i, which is the number of times the ith and jth smallest elements
of A are compared at some point in the algorithm.
i. What is the sample space of this problem?
ii. Explain why xijisan indicator random variable.
iii. What is the probability ofzi and zj being compared ifwe are trying to find the kth order
statistic, and k?
iv. What is the probability ofzi and zj being compared ifwe are trying to find the kth order
statistic, and i,j?
v. What is the probability ofzi and zj being compared ifwe are trying to find the kth order
statistic, and ikj?
vi. Use linearity of expectation, and properties of the expectation value of indicator random
variables to create an explicit expression involving sums that gives the average number of
comparisons done over the coruse of the algorithm.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Oracle9i Database Administration

Authors: Sam R. Alapati

1st Edition

1590590228, 978-1590590225

More Books

Students also viewed these Databases questions

Question

What is management growth? What are its factors

Answered: 1 week ago