hw02updated - clearer Is the modified algorithm faster...

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

View Full Document Right Arrow Icon
CSE 331: Homework 2 Spring 2008 Due by 11:59 AM Friday 25 Jan 2008, either by handin or by sliding under the door of EB 3134 Submission Submit your work via Handin. Name your file < name > Results.pdf where < name > is your last name, as in jonesResults.pdf . Problems: Do the following problems from Chapter 7 of the text. As always, we do not want just the “answers”, we want the reasoning behind the answers. 1. Show how mergesort would sort the 8-element sequence 5, 9, 16, 8, 2, 32, 4, 12. Show how the sequence would be broken down into sublists, then show the results of each of the merge steps. For this problem, it is sufficient to give the different lists without explanation. 2. Discuss how to modify quicksort to efficiently sort only the largest 0 . 05 N elements in the input sequence. You do not need to provide any explicit code examples, but you may choose to if you feel it makes your explanation
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: clearer. Is the modified algorithm faster than Ω( NlogN ) in the best case? Why or why not? 3. Do problem 7.31 from the text for insertion sort, bubble sort, mergesort, and quicksort. If there is an obvious and easy way to make the sort stable, assume that it is part of the algorithm and state what it is. 4. Consider problem 7.38 from the text. (a) Give a clearly O ( N ) algorithm for finding the median. (b) Now give an algorithm that is O ( logN ), as asked in the text. Be sure to include an argument for why your algorithm is O ( logN ). Note that A and B represent sets in this problem. You may assume that there are no duplicate elements in A and that there are no duplicate elements in B. 5. Give a format argument, based on the definition of Big Theta, proving that f ( N ) = 3 N 2-7 N + 5 is Θ( N 2 ). 1...
View Full Document

This note was uploaded on 07/25/2008 for the course CSE 331 taught by Professor M.mccullen during the Spring '08 term at Michigan State University.

Ask a homework question - tutors are online