assignments - Hint 2 The class InsertionSort contains the...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Lab Tasks 10 1. Complete the methods name and matricNumber in class task0.NameAndMarticNumber. 2. The interface Comparable in Java provides a way compareTo to compare two elements. The interface ThreeWayComparable in package insertionSort contains a method threeWayCompareTo, which compares three elements, as described in the comments. Make use of this method in a new version of Insertion Sort, in the class ThreeWayInsertionSort. You should full use of the method threeWayCompareTo in the inner loop of Insertion Sort; instead of going down one step at a time, you should be able to go down two steps at a time, most of the time. Hint 1 You can test your program using the class ThreeWayInteger as shown in the class ThreeWayIntegerTest.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Hint 2 The class InsertionSort contains the version presented in the lectures. 3. This question uses the same idea as the previous question, namely three-way comparison. Now the target is a new version of Mergesort. In order to make full use of threeWayCompareTo, your version should split the given array into three sub-array, instead of two, as in the original version of Mergesort. Implement the method mergeSort in class ThreeWayMergeSort. Of course you can add helper methods. Hint 1 You can test your program using the class ThreeWayInteger as shown in the class ThreeWayIntegerTest. Hint 2 The class MergeSort contains the version presented in the lectures. 1...
View Full Document

This note was uploaded on 06/09/2011 for the course CS 11025 taught by Professor Nil during the Spring '11 term at National University of Singapore.

Ask a homework question - tutors are online