You are on page 1of 1

Joseph Izon 202605

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

DOG SEA BAR BAR


POG MOB SEA BOX
SEA DOG MOB DOG
RUG POG DOG MOB
SUS  RUG  POG  POG
ROW BAR ROW ROW
MOB SUS BOX RUG
BOX ROW RUG SEA
BAR BOX SUS SUS

You might also like