
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Instructions for implementing a modified bubble sort algorithm that sorts elements in both directions, and an improved quick sort algorithm that utilizes insertion sort for small lists. Students are required to experimentally determine the threshold for when insertion sort is faster than quick sort, and submit the necessary files for both sorts along with a timing report.
Typology: Slides
1 / 1
This page cannot be seen from the preview
Don't miss anything!

Objective: Become more proficient at implementing sorting algorithms.
Part A: Implement a modified bubble sort algorithm to “bubble” in both directions. The first pass through the “unsorted” part of the array bubbles the largest item to the right end of the “unsorted” part. The second pass through the “unsorted” part of the array bubbles the smallest item to the left end of the “unsorted” part. This alternating pattern continues until no more passes are necessary.
sorted part sorted part (smallest items) (largest items) unsorted items
Part B: The advanced sorts like quick sort ( O (n log 2 n) in the average-case) are faster than the simple sorts ( O (n^2 ) on average) when n is large, but the simple sorts are actually faster when n is “small”. By experimenting with timing the existing sorts from lab 8 determine the threshold of when the insertion sort (a simple sort) is faster on randomly ordered lists than quick sort on your computer. THEN, implement an improved quick sort that utilizes insertion sort on small (i.e., less than your threshold) length lists. In addition to your code, include a report of the timing improvement of your improved quick sort over the original quick sort from lab 8.
SUBMISSION Submit ALL necessary files to run your sorts as a single zipped file (called hw5.zip) electronically at
https://www.cs.uni.edu/~schafer/submit/which_course.cgi
Include in your hw5.zip file a "report" file for part B (hw5.doc, .txt,.rtf, .odt, etc.) containing the timing results for your improved quick sort vs. the original quick sort.