This preview shows page 1. Sign up to view the full content.
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
This is the end of the preview. Sign up
to
access the rest of the document.
This note was uploaded on 07/25/2008 for the course CSE 331 taught by Professor M.mccullen during the Spring '08 term at Michigan State University.
 Spring '08
 M.McCullen
 Algorithms, Data Structures, Insertion Sort

Click to edit the document details