CSE331 Homework 3 (Jan. 29 Update)
Due: Friday Feb. 1, 2008 at 11:59am
1.
Show how the quicksort algorithm (page 286, but let the quicksort work all the
way to size 1 and 0 rather than calling insertion sort) sorts the following list:
Index:
0
1
2
3
4
5
6
7
8
Key:
414
132
327
554
877
542
433
986
233
Draw the calling diagram as a tree, where each node corresponds to a quicksort
call.
The root is the original call.
In each node:
a.
Provide the A array right after the pivot is restored.
b.
Give the
parameters of every call, including the content of the A array, left
and right parameters.
The order of the numbers in A array needs to be correct.
2.
(Problem 7.32 (ac) on page 309.) Suppose you are given a sorted list of N
elements, followed by f(N) randomly ordered elements. How would you sort the
entire list if
(a)
f(N) = O(1) ?
(b)
f(N) = O(log N) ?
(c)
f(N) = O( sqrt (N) ) ?
Describe your algorithm in detail for each size N.
Try to keep the running time of
your algorithm as efficient as possible.
Additionally, provide the complexity (in
terms of big O) of each of your algorithms.
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '08
 M.McCullen
 Algorithms, Data Structures, Insertion Sort, Big O notation

Click to edit the document details