Question: 7 . 4 - 2 Show that quicksort's best - case running time is ( n l g n ) . The analysis of the
Show that quicksort's bestcase running time is
The analysis of the expected running time of randomized quicksort in Section
assumes that all element values are distinct. In this problem, we examine what
happens when they are not.
a Suppose that all element values are equal. What would be randomized quick
sort's running time in this case?
b The Partition procedure returns an index such that each element of
is less than or equal to and each element of dotsr
is greater than Modify the Partition procedure to produce a procedure
Partition which permutes the elements of and returns two
indices and where such that
all elements of are equal,
each element of is less than and
each element of dotsr is greater than
Like PARTITION, your PARTITION' procedure should take time.
c Modify the RANDOMIZEDQUICKSORT procedure to call Partition', and
name the new procedure RANDOMIZEDQUICKSORT Then modify the
QUICKSORT procedure to produce a procedure that calls
RANDOMIZEDPARTITION and recurses only on partitions of elements not
known to be equal to each other.
d Using QUICKSORT', how would you adjust the analysis in Section to
avoid the assumption that all elements are distinct?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
