Question: Java - Quicksort Problem Implementing 5 different variations of the quicksort algorithm and compare their relative speed using 10 different input sequences import java.util.*; /*

Java - Quicksort Problem Implementing 5 different variations of the quicksort algorithm and compare their relative speed using 10 different input sequences

import java.util.*;

/* * Quicksort Implementation with Five Pivot Choice techniques * and * Input Sequence Data Generator * */ public class QuickSort { public int QuickSortPivotA(int [] array) { /* Implement the quicksort with pivot as the last element of the sequence. The method to sort array in place in ascending order the method is to return the number of comparisons required to complete the sorting. */

return 0; } public int QuickSortPivotB(int [] array) { /* Implement the quicksort with pivot as the first element of the sequence. The method to sort array in place in ascending order the method is to return the number of comparisons required to complete the sorting. */

return 0; } public int QuickSortPivotC(int [] array) { /* Implement the quicksort with pivot as the middle element of the sequence. The method to sort array in place in ascending order the method is to return the number of comparisons required to complete the sorting. */

return 0; } public int QuickSortPivotD(int [] array) { /* Implement the quicksort with pivot as the median of the first, middle and last elements of the sequence. The method to sort array in place in ascending order the method is to return the number of comparisons required to complete the sorting. */ return 0; }

public int QuickSortPivotE(int [] array) { /* Implement the quicksort with pivot as the median of five elements of the sequence, chosen to be roughly 10%, 30%, 50%, 70% and 90% of the way through the sequence. The method to sort array in place in ascending order the method is to return the number of comparisons required to complete the sorting. */

return 0; } /* * * Implement the rest of the functions required to do the quicksort for every variation. * */ public int[] GenerateInputSequence1(int N) { /* * return an array with the sequence 1, 2, 3, ..., N (in increasing order). * For example, if N = 1000, then the sequence would be: 1, 2, 3, 4, 5, ..., 1000 * */ return null;

} public int[] GenerateInputSequence2(int N) { /* * return an array with The sequence N, N-1, ..., 2, 1 (in decreasing order). * For example, if N = 1000, then the sequence would be: 1000, 999, ..., 2, 1 * */

return null; }

public int[] GenerateInputSequence3(int N) { /* * return an array with The sequence 1, 3, 5, ..., N-1, 2, 4, 6, ..., N. * For example, if N = 1000, then the sequence would be: 1, 3, 5, ..., 999, 2, 4, 6, ..., 1000 * */

return null; } public int[] GenerateInputSequence4(int N) { /* * return an array with the sequence 1, 3, 5, ..., N-3, N-1, N, N-2, N-4, ..., 4, 2. * For example, if N = 1000, then the sequence would be: 1,3,5 ...,997,999,1000,998,996, ..., 4,2 * */

return null; }

public int[] GenerateInputSequence5(int N) { /* * return an array with sequence 1, N, 2, N-1, 3, N-2, 4, N-3, ..., N/2, (N/2)+1. * For example, if N = 1000, then the sequence would be: 1, 1000, 2, 999, 3, 998, 4, 997, ..., 500, 501 * */

return null; } public int[] GenerateInputSequence6(int N) { /* * return an array with the sequence: Each number is (7 + the previous number) mod N. * That is, a(i) = (7 + a(i-1)) mod N, a(0)=0 * For example, if N = 1000, then the sequence would be: 0, 7, 14, ..., 994, 1, 8, ..., 993 */

return null;

}

public int[] GenerateInputSequence7(int N) { /* * return an array with The sequence: The first N Fibonacci numbers modulo N: * a(0) = 0; a(1) = 1; a(i) = (a(i-1) + a(i-2)) mod N for 1

return null; }

public int[] GenerateInputSequence8(int N) { /* * return an array with The sequence The first N powers of 2 modulo N: * a(0) = 1; a(i) = (2*a(i-1)) mod N for 0

Java - Quicksort Problem Implementing 5 different variations of the quicksort algorithm

and compare their relative speed using 10 different input sequences import java.util.*;

Insertion sort: Java implementation publ1c class Insertion public static void sort (Comparable[] a) intN-a.length; for (int 1-0; 1 0; j--) if (less(aj], aj-1])) exch(a, j, j-1); else break; private static boolean less (Comparable v, Comparable w) as before* private static void exch(Comparable[] a, int i, int j) I /*as before*

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!