hw02updated

hw02updated - clearer Is the modiﬁed algorithm faster...

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

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
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: clearer. Is the modiﬁed 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 ﬁnding 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 deﬁnition of Big Theta, proving that f ( N ) = 3 N 2-7 N + 5 is Θ( N 2 ). 1...
View Full Document

{[ snackBarMessage ]}

What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern