hwk6 - Fall 2011 CMSC 351: Homework 6 Clyde Kruskal Due at...

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

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

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

This note was uploaded on 01/13/2012 for the course CMSC 351 taught by Professor Staff during the Fall '11 term at University of Louisville.

Ask a homework question - tutors are online