Question: JAVA eclipse. Please help me! Create a class called Sort that has three static methods for sorting integer arrays. All three methods should accept an
JAVA eclipse. Please help me!
Create a class called Sort that has three static methods for sorting integer arrays. All three methods should accept an array of integers, have void return type, and should sort the array in-place.
1.
public static void bubbleSort(int[] array) {
// your code here
}
2.
public static void insertionSort(int[] array) {
// your code here
}
3.
public static void selectionSort(int[] array) {
// your code here
}
View required output
Test Case 1
| Standard Input | Files in the same directory |
|---|---|
3 2 1ENTER quitENTER | SortTester.java |
Please enter a space separated list of numbers to sort or type QUIT to exit: Sorted array using Bubble Sort algorithm: 1 2 3 Sorted array using Insertion Sort algorithm: 1 2 3 Sorted array using Selection Sort algorithm: 1 2 3 Please enter a space separated list of numbers to sort or type QUIT to exit:
Test Case 2
| Standard Input | Files in the same directory |
|---|---|
1ENTER -100ENTER 1 2ENTER 2 1ENTER 1 2 3ENTER 3 2 1ENTER 2 3 1ENTER 1 3 2ENTER quitENTER | SortTester.java |
Please enter a space separated list of numbers to sort or type QUIT to exit: Sorted array using Bubble Sort algorithm: 1 Sorted array using Insertion Sort algorithm: 1 Sorted array using Selection Sort algorithm: 1 Please enter a space separated list of numbers to sort or type QUIT to exit: Sorted array using Bubble Sort algorithm: -100 Sorted array using Insertion Sort algorithm: -100 Sorted array using Selection Sort algorithm: -100 Please enter a space separated list of numbers to sort or type QUIT to exit: Sorted array using Bubble Sort algorithm: 1 2 Sorted array using Insertion Sort algorithm: 1 2 Sorted array using Selection Sort algorithm: 1 2 Please enter a space separated list of numbers to sort or type QUIT to exit: Sorted array using Bubble Sort algorithm: 1 2 Sorted array using Insertion Sort algorithm: 1 2 Sorted array using Selection Sort algorithm: 1 2 Please enter a space separated list of numbers to sort or type QUIT to exit: Sorted array using Bubble Sort algorithm: 1 2 3 Sorted array using Insertion Sort algorithm: 1 2 3 Sorted array using Selection Sort algorithm: 1 2 3 Please enter a space separated list of numbers to sort or type QUIT to exit: Sorted array using Bubble Sort algorithm: 1 2 3 Sorted array using Insertion Sort algorithm: 1 2 3 Sorted array using Selection Sort algorithm: 1 2 3 Please enter a space separated list of numbers to sort or type QUIT to exit: Sorted array using Bubble Sort algorithm: 1 2 3 Sorted array using Insertion Sort algorithm: 1 2 3 Sorted array using Selection Sort algorithm: 1 2 3 Please enter a space separated list of numbers to sort or type QUIT to exit: Sorted array using Bubble Sort algorithm: 1 2 3 Sorted array using Insertion Sort algorithm: 1 2 3 Sorted array using Selection Sort algorithm: 1 2 3 Please enter a space separated list of numbers to sort or type QUIT to exit:
Test Case 3
| Standard Input | Files in the same directory |
|---|---|
QuitENTER | SortTester.java |
Please enter a space separated list of numbers to sort or type QUIT to exit: Sorted array using Bubble Sort algorithm: Sorted array using Insertion Sort algorithm: Sorted array using Selection Sort algorithm: Please enter a space separated list of numbers to sort or type QUIT to exit:
Test Case 4
| Standard Input | Files in the same directory |
|---|---|
0ENTER qUitENTER | SortTester.java |
Please enter a space separated list of numbers to sort or type QUIT to exit: Sorted array using Bubble Sort algorithm: 0 Sorted array using Insertion Sort algorithm: 0 Sorted array using Selection Sort algorithm: 0 Please enter a space separated list of numbers to sort or type QUIT to exit:
Test Case 5
| Standard Input | Files in the same directory |
|---|---|
1 2 3 10 9 7 8 9 9 9 9 9 1 1 1 1 2 2 2 2 10 10 10 7 7 7 -100ENTER QUIT | SortTester.java |
Please enter a space separated list of numbers to sort or type QUIT to exit: Sorted array using Bubble Sort algorithm: -100 1 1 1 1 1 2 2 2 2 2 3 7 7 7 7 8 9 9 9 9 9 9 10 10 10 10 Sorted array using Insertion Sort algorithm: -100 1 1 1 1 1 2 2 2 2 2 3 7 7 7 7 8 9 9 9 9 9 9 10 10 10 10 Sorted array using Selection Sort algorithm: -100 1 1 1 1 1 2 2 2 2 2 3 7 7 7 7 8 9 9 9 9 9 9 10 10 10 10 Please enter a space separated list of numbers to sort or type QUIT to exit:
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
