Unformatted text preview: Fall 2011 CMSC 351: Homework 6 Clyde Kruskal Due at the start of class Wednesday, October 19, 2011. Problem 1. Consider an array of size eight with the numbers 50 , 70 , 10 , 20 , 60 , 40 , 80 , 30. Assume you execute quicksort using the version of partition from CLRS. Note that in this algorithm an element might exchange with itself (which counts as one exchange). (a) Show the array after the first partition. How many comparisons and exchanges are used? (b) Show the left side after the next partition. How many comparisons are used? How many exchanges? (c) Show the right side after the next partition on that side. How many comparisons are used? How many exchanges? (d) What is the total number of comparisons in the entire algorithm? What is the total number of exchanges in the entire algorithm? Problem 2. We are going to derive the average number of moves for quicksort using a somewhat unusual partitioning algorithm. We partition on the first element. Take it out. Look for the right most element that is smaller and place it in the first position (which is the newly opened...
View
Full Document
 Fall '11
 Staff
 French Revolution, Big O notation, Leftwing politics

Click to edit the document details