Homework 51

.pdf

School

University Of Arizona *

*We aren’t endorsed by this school

Course

305

Subject

Computer Science

Date

Apr 3, 2024

Type

pdf

Pages

1

Uploaded by MagistrateQuetzal3896

Homework 5 Due: Tuesday 2 April 2024 by 11:59 PM Instructions. Type your answers to the following questions and submit as a single PDF on Gradescope by the due date and time listed above. (You may write your solutions by hand, but remember that it is at your own risk as illegible solutions will not receive credit.) Assign pages to questions when you submit. Failure to do this will result in a deduction from your grade. For all questions, you must show your work and/or provide a justification for your answers. Question 1. (a) Give a recurrence relation for the best and worst-case runtimes of Mergesort and explain each part of it with respect how the algorithm works. (b) Give the best and worst-case runtimes for Mergesort in big-Oh notation and justify your answers based on the recurrence relations. Question 2. (a) Give a recurrence relation for the best and worst-case runtimes of Heapsort and explain each part of it with respect how the algorithm works. (b) Give the best and worst-case runtimes for Heapsort in big-Oh notation and justify your answers based on the recurrence relations. Question 3. (a) Give a recurrence relation for the best and worst-case runtimes of Quicksort and explain each part of it with respect how the algorithm works. (b) Give the best and worst-case runtimes for Quicksort in big-Oh notation and justify your answers based on the recurrence relations. Question 4. Explain why the randomization of the pivot is important for Quicksort. Question 5. In PA 3 you were asked to implement two locality-aware sorting algorithms–one based on Selection Sort and one based on Heapsort. As a reminder, a locality-aware array is one where we know that each value in the array is not going to move more than d positions away from where it starts when the array is sorted. (a) Explain why a locality-aware version of Insertion Sort would not improve upon the runtime for regular Insertion Sort. (b) Explain how you would implement a locality-aware version of Mergesort and analyze the runtime. Question 6. Make sure you assign pages to questions correctly on Gradescope.
Discover more documents: Sign up today!
Unlock a world of knowledge! Explore tailored content for a richer learning experience. Here's what you'll get:
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help