Computer Science 60
Principles of Computer Science

Assignment 10: Sorting and Spampede (Starter)!
Due Tuesday 19th by 11:59 PM

Pair programming is permitted on all parts of this week's assignment.

This week you will work on implementing bubble sort, insertion sort, and selection sort in Prolog, Java, and Racket.


Sorting (65 points)

To reinforce some of the sorting algorithms you've learned in CS 60, you'll be implementing these sorting algorithms in each of the three languages from CS60.

In the hw10 directory you'll find:

The Java starter file provides the following method signatures. We are using the SortingStuff class, but do not plan to make SortingStuff objects and you will write the following static methods for the class.

	public static boolean bubble(int[] arr) {
	public static int bubbleSort(int[] arr) {
	public static void insert(int[] arr, int index) {
	public static void insertionSort(int[] arr) {
	public static int minIndex(int[] arr, int startIndex) {
	public static void selectionSort(int[] arr) {

The Racket starter file provides approximately half of the functions necessary for sorting. The following functions are provided: selectionSort, insertionSort, and bubble. You will write the following functions:

	min
	remove
	insert
	bubbleSort

The Prolog starter file provides approximately half of the predicates necessary for sorting. The following predicates are provided: min, remove, insert, and bubbleSort. You will write the following predicates:

	selectionSort 
	insertionSort 
	bubble

Test cases are provided for all of the sorting [methods/functions/predicates]. Before writing the code for any of these [methods/functions/predicates] you should provide comments describing why each test case is important. For example, you might describe the base case or corner case that a test checks. If there is important functionality that won't be tested by the provided test cases, you should add test cases. One purpose of this is to get familiar with what each of these [methods/functions/predicates] does before trying to figure out how it does that.

Part 2: Big-O running times...

35 points

For these questions, you will be analyzing the running time of algorithms. We will be interested in worst-case analysis. You will need to express the worst-case running time using big-O notation. In addition to your answers, be sure to show your reasoning for each of the problems in the hw10pr2.txt file (just as ASCII text).

Submitting these answers    Include your answers to these problems in the hw10pr2.txt file.


Extra Credit

Using the List class from Homework 6, implement and test:

You will turn in both List.java and ListTest.java. Half of the points will be based upon your thorough testing of the sorting method and testing any helper methods you write. Please use the following signatures. Your methods should modify the List. You shouldn't create any new ListNodes (i.e., you shouldn't call new ListNode()), but you may create additional ListNode references. You may create additional Lists (i.e., you can call new List()).

	public void quickSort()
	public void bubbleSort()