404_HW6_F11 - (including swaps needed to build the heap)?...

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

View Full Document Right Arrow Icon
UML CS Analysis of Algorithms 91.404 (section 201) Fall, 2011 Homework Set #6 Assigned: Monday, 10/17 Due: Monday, 10/24 (start of lecture) This assignment covers textbook material in Chapter 7. Note: Partial credit for wrong answers is only given if work is shown. 1. (25 points) QUICKSORT vs. HEAPSORT: This problem uses array A = < 18, 34, 22, 7 > from. Apply QUICKSORT to array A to sort it into non-decreasing order. Use the (nonrandomized) version of PARTITION given on p. 171 of the text. (a) Illustrate the operation of QUICKSORT on A using Figure 7.1 on p. 172 as a model for the operation of PARTITION . (b) How many swaps are performed by QUICKSORT to sort A ? How does this compare with the number of swaps that would be used by HEAPSORT for this same array
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: (including swaps needed to build the heap)? How meaningful is this result in terms of comparing the asymptotic running time of the two sorting procedures? 2 . (30 points) QUICKSORT Analysis: Textbook Exercise 7.4-2 on p. 184. 3 . (10 points) Suppose that the PARTITION procedure of QUICKSORT is modified to always use the first element as the pivot (instead of the last element). In this case: a) Provide an example of an array of elements that constitutes a worst-case input for the revised QUICKSORT procedure. b) Provide an example of an array of elements that constitutes a best-case input for the revised QUICKSORT procedure. 4. (35 points) Hoare Partition : Textbook Problem 7-1 on p. 185-186, parts (a)-(d)...
View Full Document

This note was uploaded on 02/13/2012 for the course CS 91.404 taught by Professor Dr.karendaniels during the Fall '09 term at UMass Lowell.

Ask a homework question - tutors are online