how do you test sorting methods which accepts comparable data with integers? Also did i put the counters of comparisons at the right place on each Sorting method? I am supposed to compare the number of comparisons each sorting method makes. any help appretiated http://pastebin.com/embed_js.php?i=KZYJJr7L
Ok well first off there is a class called comparator you might want to look at.
But that works on it's own comparing which I believe is a merge sort.
Also I noticed that for (int index = 0; index < data.length-1; index++) { it should be index <= data.length-1 or <data.length imo.
Since if it's 0-9 and the length is 10 then, and then you're looking for < length -1 so it would be <9 and that last variable isn't looked at.
For each of your for loops it seems you're changing it up, I'm going to look at this a little more.
thanks for the reply, the assignment is that, we are given the whole sorting class(one i posted) and we are supposed to have a tester class with integers and record the time it takes to sort. ""For this part, you will compare the performance of the sorting algorithms on different lists. You should output the number of comparisons each sorting algorithm makes for each list. Generate the following 5 lists in 4 sizes (10, 100, 1,000, & 10,000 elements): 1. Increasing order (1, 2, 3, . . . ) 2. Reverse order (10,000/1000/100/10 . . . .1) 3. Three randomly generated lists (make sure they are different!)"" but i could not enter an array to be sorted since its accepting comparable
Join our real-time social learning platform and learn together with your friends!