Question: Using the Sorting.java file, modify the program to investigate the behavior ( best , worst, average ) of insertion sort and three diminishing increments for
"Using the Sorting.java file, modify the program to investigate the behavior best worst, average of insertion sort and three diminishing increments for Shell sort. Run your program for a range of array sizes. Record the data that you obtain in a table in a Word document. Write a narrative describing your findings. Turn in the Word doc." make an insertion sort graph and a shell sort graph, specifically for the average case. graph swaps over array size. for the best case, no graph is needed, but a write couple of sentences explaining why there are no swaps. for the worst case, create an analysis and a graph. import java.util.Random; import java.util.Scanner; public class Sorting public static void mainString args int increments null; Scanner scr new ScannerSystemin; long swaps; long beginTime, endTime; whiletrue int n scrnextInt; ifn break; int A new intn; long seed scrnextLong; Insertion sort increments new int; increments; initArrayAseed; beginTime System.nanoTime; swaps shellSortAincrements; endTime System.nanoTime; System.out.printlnInsertion sort swaps swaps timeendTimebeginTimems; Shell sort with powers of increments int numIncr intMathlognMathlog; increments new intnumIncr; incrementsnumIncr; forint inumIncr; i; i incrementsi incrementsi; initArrayAseed; beginTime System.nanoTime; swaps shellSortAincrements; endTime System.nanoTime; System.out.printlnShell sort powers of swaps swaps timeendTimebeginTimems; Shell sort with k increments increments new intnumIncr; incrementsnumIncr; int power ; forint inumIncr; i; i power ; incrementsi power ; initArrayAseed; beginTime System.nanoTime; swaps shellSortAincrements; endTime System.nanoTime; System.out.printlnShell sort with k increments swaps swaps timeendTimebeginTimems; Shell sort with k increments numIncr intMathlognMathlog; increments new intnumIncr; incrementsnumIncr; power ; forint inumIncr; i; i power ; incrementsipower; initArrayAseed; beginTime System.nanoTime; swaps shellSortAincrements; endTime System.nanoTime; System.out.printlnShell sort with k increments swaps swaps timeendTimebeginTimems; scrclose; static void initArrayint A long seed Random rnd new Randomseed; for int i; i incr && Aj
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
