Download selectionsort

Page 1

Download:

http://solutionzip.com/downloads/selectionsort/

Requirements: Compare the efficiency of Selection Sort, Insertion Sort and Quicksort. Approach: Starting from your second homework assignment, evaluate the efficiency of Selection Sort, Insertion Sort and Quicksort. For doing this, you should evaluate their corresponding implementations in each of the 3 cases (best, worst, and average) and count the number of operations performed (assignments, comparisons, and overall, separately). Selection Sort code: // Method: selectionSort // Author: instructorX // Date: dd/mm/yyyy // Purpose: A method that sorts an array using a selection sort public static void selectionSort(Comparable[] array) { int i; for (i = 0; i < array.length; i++) { int minIndex = i; for (int j = i + 1; j < array.length; j++) if (array[j].compareTo(array[minIndex]) < 0) minIndex = j; swap(array, minIndex, i);


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.