Assignment 1: Guide – SWE 619 – ALL – Spring 2010

 

Goal: Basic familiarity with Java.

 

Basic Assignment

 

Our first assignment will be to implement an Insertion Sort:

 

Define a Java class call insertionSort that satisfies the following specification:

 

Requires: a sequence of n numbers (a1, a2, … , an)

 

Effects: return a permutation (reordering) (a’1, a’2, … , a’n)

 

Consider the following algorithm for Insertion Sort:

 

for j <- to length[A]

do key <- A[j]

        //Insert A[j] into the sorted sequence A[1 .. j - 1]

        i <- j - 1

        while I > 0 and A[i] > key

                do A[i + 1] <- A[i]

                    i <- i – 1

        A[i + 1] <- key

 

Utilize a java Applet to input your sequence.

 

Submit the following:

 

1)   Java source file.

2)   Output file – including the following input cases: empty sequence; one element sequence; ordered sequence, and several unordered sequences.