hw03 - CSE331 Homework 3 Due: Friday Feb. 1, 2008 at...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE331 Homework 3 Due: Friday Feb. 1, 2008 at 11:59am 1. Show how the quick-sort algorithm (page 286, but let the quick-sort 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 quick-sort 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 (a-c) 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
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.
Ask a homework question - tutors are online