Question: Write a program that will display the below menu. [1] Selection Sort [2] Insertion Sort [3] Bubble Sort [4] Exit Using array of integer with
Write a program that will display the below menu.
[1] Selection Sort
[2] Insertion Sort
[3] Bubble Sort
[4] Exit
Using array of integer with a size of 10, the program will allow the user to select from the above options. Use the below program structure and complete the five methods.
public class SortingAlgo {
public static void Print(int arr[]) {
// To complete
}
public static void Selection(int arr[]) {
// To complete
}
public static void Insertion(int arr[]) {
// To complete
}
public static void Bubble(int arr[]) {
// To complete
}
public static void main(String args[]) {
// To complete
}
}
Your program output should be similar to the following.
[1] Selection
[2] Insertion
[3] Bubble
[4] Exit
Choose an option: 1
--Selection sort iterations--
5 3 8 2
2 3 8 5
2 3 8 5
2 3 5 8
[1] Selection
[2] Insertion
[3] Bubble
[4] Exit
Choose an option: 2
--Insertion sort iterations--
5 3 8 2
3 5 8 2
3 5 8 2
2 3 5 8
[1] Selection
[2] Insertion
[3] Bubble
[4] Exit
Choose an option: 3
--Bubble sort iterations--
5 3 8 2
3 5 8 2
3 5 2 8
3 2 5 8
2 3 5 8
[1] Selection
[2] Insertion
[3] Bubble
[4] Exit
Choose an option: 4
Bye!!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
