Quicksort - Divider and Conquer
Illustrate the operation of PARTITION on the array:
A = {9, 19, 13, 5, 12, 8, 7, 4, 21, 6, 11}.
Let A[1] = 9 be the pivot value.
Trace the execution of quicksort on the following array,
assuming that the first item in each subarray is the pivot value.
Show the values of first and last for each recursive call and the
array elements after returning from each call. Also, show the value
of pivot during each call and the value returned through pivIndex.
How many times is sort called, and how many times is partition
called? 55 50 10 40 80 90 60 100 70 80 20...
What is the running time of QUICKSORT on an array A of length n
containing all the same values? What is the running time if A
contains distinct elements sorted in decreasing order? Explain your
answers in detail, referring to the source code for PARTITION and
QUICKSORT.
Consider QuickSort on the array A[1:n] and
assume that the pivot element x (used to split the array A[lo:hi]
into two portions such that all elements in the left portion
A[lo:m] are =< x and all elements in the right portion A[m:hi]
are >=x) is the first element of the array to be split (i. e.,
A[lo]).Construct an infinite sequence of numbers for n and construct an
assignment of the numbers 1...n to the n array elements that causes
QuickSort,...
. Consider QuickSort on the array A[1:n] and assume that the
pivot element x (used to split the array A[lo:hi] into two portions
such that all elements in the left portion A[lo:m] are ≤x and all
elements in the right portion A[m:hi] are ≥x) is the
second element of the array to be split (i. e.,
A[lo+1]).
For a specific value of n at least
13 (your choice), construct an assignment of the
numbers 1...n to the n array elements...
Consider QuickSort on the array
A[1:n] and assume that the pivot element x (used to split the array
A[lo:hi] into two portions such that all elements in the left
portion A[lo:m] are ≤x and all elements in the right portion
A[m:hi] are ≥x) is the second element of the array
to be split (i. e., A[lo+1]).
For a specific value of n at least
13 (your choice), construct an assignment of the
numbers 1...n to the n array elements that...