hw3solution - CS 161 Summer 2009 Homework#3 Sample...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

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

Unformatted text preview: CS 161 Summer 2009 Homework #3 Sample Solutions Regrade Policy: If you believe an error has been made in the grading of your homework, you may resubmit it for a regrade. If the error consists of more than an error in addition of points, please include with your homework a detailed explanation of which problems you think you deserve more points on and why. We reserve the right to regrade your entire homework, so your final grade may either increase or decrease. Problem 1 [5 points] What really is important for ”on-disk” sorting approaches is less about memory usage and more about how many times we’re going to have to visit the disk. In practice, Merge-Sort is the algorithm that is amenable to ”on-disk” sorting. De- pending on the data set and implementation, Quicksort can also be feasible. The other algorithms have varying issues described below that tend to account for too many disk accesses. As mentioned above, Merge-Sort is very good for this since once we’ve split the data down to small enough chunks to process in memory, we only need to process on those chunks until we need to do the final merger of the larger chunks. Even the merger of the larger chunks is fairly disk friendly since it’s just a traversal of data one element at a time starting at the beginning of a chunk of memory. If you look at the unix/linux ”sort” function, which does on disk sorting, Merge-Sort is used. Algorithms like Insertion-Sort and bubble sort that make multiple passes over all of the data tend to perform poorly because they’re accessing all of the data over and over again and must continually read that data off disk and get very little ”reuse” of the data that is...
View Full Document

This document was uploaded on 05/25/2011.

Page1 / 6

hw3solution - CS 161 Summer 2009 Homework#3 Sample...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online