Docsity

STOOGE-SORT Algorithm Analysis, Assignments of Computer Science

Toggle sidebar
bg1
Written Assignment III
COP3502H
Due: Wednesday, 4/11/07 in class
Make sure you show all you work and start early.
From “Data Structures, Algorithms, and Software Principles in C”
1. page 547, #1,2
2. page 551, #1
3. page 571, #1
Also do this problem:
Professors Howard, Fine, and Howard have proposed the following sorting algorithm:
STOOGE-SORT(A,i,j)
if A[i] >A[j]
swap (A[i], A[j]);
if i+1 ≥ j
return;
k = ⎣(j-i+1)/3⎦; // round down
STOOGE-SORT(A,i,j-k); // first two-thirds
STOOGE-SORT(A,i+k,j); // last two-thirds
STOOGE-SORT(A,i,j-k); // first two thirds again
a). Argue that STOOGE-SORT(A,1, length[A]) correctly sorts the input array
A[1..n], where n=length[A].
b). Give a recurrence for the worst-case running time of STOOGE-SORT. Solve the
recurrence relation and find the running time using Big-O notation.
c). Compare the worst case running time of STOOGE-SORT with that of insertion sort,
merge sort, bubble sort, and quicksort. Doe the professors deserve tenure?

Partial preview of the text

Download STOOGE-SORT Algorithm Analysis and more Assignments Computer Science in PDF only on Docsity!

Written Assignment III

COP3502H

Due: Wednesday, 4/11/07 in class

Make sure you show all you work and start early.

From “Data Structures, Algorithms, and Software Principles in C”

  1. page 547, #1,
  2. page 551, #
  3. page 571, #

Also do this problem:

Professors Howard, Fine, and Howard have proposed the following sorting algorithm:

STOOGE-SORT(A,i,j)

if A[i] >A[j] swap (A[i], A[j]); if i+1 ≥ j return; k = ⎣(j-i+1)/3⎦; // round down STOOGE-SORT(A,i,j-k); // first two-thirds STOOGE-SORT(A,i+k,j); // last two-thirds STOOGE-SORT(A,i,j-k); // first two thirds again

a). Argue that STOOGE-SORT(A,1, length[A]) correctly sorts the input array A[1..n], where n=length[A].

b). Give a recurrence for the worst-case running time of STOOGE-SORT. Solve the recurrence relation and find the running time using Big-O notation.

c). Compare the worst case running time of STOOGE-SORT with that of insertion sort, merge sort, bubble sort, and quicksort. Doe the professors deserve tenure?