Sorting PDF
Sorting PDF
Class: Array
import java.util.*;
String s;
int arr[];
Scanner input = new Scanner(System.in);
public Array(){
System.out.println("Output");
for(int x = 0; x < arr.length; x++)
System.out.println(arr[x]);
}
Class: BubbleSort
int x, y;
}
Class: SelectionSort
int hold = y;
}
Class: InsertionSort
}
Class: QuickSort
int pi;
int i = low - 1;
int pivot = arr[high];
return i + 1;
}
}
Class: MargeSort
}
Class: ShellSort
}
Class: Execute
import java.util.*;
public class Execute {
System.out.println("input"
+ "\n 1 for bubble sort,"
+ "\n 2 for selection sort,"
+ "\n 3 for insertion sort,"
+ "\n 4 for quick sort,"
+ "\n 5 for marge sort,"
+ "\n 6 for shell sort");
switch(input.nextInt()) {
case 1:
obj = new BubbleSort();
break;
case 2:
obj = new SelectionSort();
break;
case 3:
obj = new InsertionSort();
break;
case 4:
obj = new QuickSort();
break;
case 5:
obj = new MargeSort();
break;
case 6:
obj = new ShellSort();
break;
default:
System.out.println("unexcepted input, terminating the program");
System.exit(0);
break;
obj.input();
obj.sort();
obj.display();
input.close();
System.exit(0);