
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Information about assignment 4 for the cs303: algorithms and data structures course, which was due on october 31, 2007. The assignment includes questions related to binary heaps, such as finding the least and most number of elements that can be stored, inserting elements, and finding nodes with keys less than a given value. Additionally, it covers the quicksort algorithm, including its implementation and complexity analysis when the pivot is the smallest and median element.
Typology: Assignments
1 / 1
This page cannot be seen from the preview
Don't miss anything!

CS303: Algorithms and Data Structures Fall 2007 Assignment 4 (written) Due Date: Oct 31, 2007 (during lab hours)
/* sort A[low] thru A[high] */ Procedure QUICKSORT(A, low, high)
If low >= high then return;
/* find a pivot */ P = PIVOT(A, low, high);
/* partition A using p such that A[mid] == p; all the elements A[low] through A[mid-1] are less than p; all the elements A[mid + 1] through A[high] are greater than p; */ PARTITION(A, low, high, p, mid);
/* sort the first half */ QUICKSORT(A, low, mid-1);
/* sort the second half */ QUICKSORT(A, mid +1, high);
End;
(a) Suppose PIVOT(A, low, high) always finds the smallest element in A[low] through A[high]. Describe and analyze the complexity of QUICKSORT() using O notation. (b) Suppose PIVOT(A, low, high) always finds the median element in A[low] through A[high]. Describe and analyze the complexity of QUICKSORT() using O notation.