# hw02 - clearer Is the modifed algorithm Faster than θ N...

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

CSE 331: Homework 2 Spring 2008 Due by 11:59 AM (noon) Friday 25 Jan 2008 If submitting paper, push it under the door of EB 3134. Submission Submit your work via Handin. Name your fle < 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. ±or this problem, it is su²cient to give the di³erent lists without explanation. 2. Discuss how to modiFy quicksort to e²ciently 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
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: clearer. Is the modifed algorithm Faster than θ ( N logN )? 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 fnding 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 ). With 3 days to go, the 331 sta± consider this part to be challenging. Enjoy it, but do not burn hours on it. 5. Give a Formal argument, based on the defnition oF Big Theta, proving that f ( N ) = 3 N 2-7 N + 5 is θ ( N 2 ). 1...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online