Published using Google Docs
IA 6 - Selection and Insertion Sort
Updated automatically every 5 minutes

IA 6 - Sort Assignment D - Selection and Insertion Sort

This assignment does not have you creating any new Main Class code.  You are simply to learn about the remaining sort algorithms and add the methods to your Sort class.  Details are below.

By now you already know how to bubble sort.  This assignment covers 2 additional sort algorithms:

 For each you will do two things: First you will find the code, then you will explain how it works.

Selection Sort - Add the code 30%

Need help learning about the Selection Sort algorithm, see Appendix A.

  1. Search and find copies of the java equivalent of the Selection Sort algorithm.  Add it to your SearchAndSort class as follows:
  1. public static void SelectionSort(int[] array)
  2. public static void SelectionSort(double[] array)
  3. public static void SelectionSort(String[] array)
  1. Include the source website for the code in a comment

Selection Sort - Explain the code - 30%

Create a multiline comment to answer the following:

  1. Above one of the methods, in a comment: Using the analogy of sorting Countries by their Average CO2 Emissions to explain how Selection Sort works. There is no specific right answer but this will require you to use your own words.  A one sentence explanation with just the basic principle is good enough.
  2. Find out what kind of data a Selection sort is good for and what kind of data it is bad for? That is, are there certain characteristics about the data or the current state of that data, that make this algorithm more or less efficient?  Add this to your comment.  Copying and pasting is allowed IF you also provide the URL to your source website.

Insertion Sort  - Add the code 20%

Need help learning about the Selection Sort algorithm, see Appendix A.

  1. Find a copies of the java equivalent of the code and add it to your Sort.java as follows:
  1. public static void InsertionSort(int[] array)
  2. public static void InsertionSort(String[] array)
  1. Include the source website for the code in a comment

 (more on next page)

Insertion Sort - Explain the code - 20%

Above one of the methods, in a comment: Using the analogy of sorting Cars by their Price to explain how Insertion Sort works.  There is no specific right answer.  A one sentence explanation with just the basic principle is good enough, as long as that explanation demonstrates you know the difference between the algorithms.

Find out what kind of data an Insertion Sort is good for and what kind of data it is bad for.  Add this to your comment.  Copying and pasting is allowed if you also provide the URL to your source website.


Appendix A - Learning about the Algorithms

If you were not around for the in-class explanations of the Selection and Insertion Sort algorithms (or if you just want some review), the following resources will help: