Professional Documents
Culture Documents
IZON - Quiz 7
IZON - Quiz 7
CSCI 30 B Quiz # 7
______________________________________________________________________
Problem 0-1
(a) Las Vegas algorithms are guaranteed to be correct but the running time is a random
variable.
(b) The best case for quicksort happens when the median element is selected as the pivot, which
would partition the array into two equal halves.
(c) On the other hand, the worst case for quicksort happens when either the minimum or
maximum element is selected as the pivot, which would partition the array (of n elements) into
one subarray of size n-1 elements and another subarray of size 0 elements .
(d) A stable sort preserves the relative order of the elements in case of ties.
Problem 0-2