Skip to content

Commit

Permalink
new version with run all sorting and .jar built with jdk 1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarneiva committed Apr 6, 2024
1 parent 832569c commit 45392ef
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 35 deletions.
2 changes: 1 addition & 1 deletion data/data.csv

Large diffs are not rendered by default.

Binary file modified out/artifacts/AmazingSort_jar/AmazingSort.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion out/artifacts/AmazingSort_jar/data/data.csv

Large diffs are not rendered by default.

Binary file modified out/production/AmazingSort/amazingsort/AmazingSort.class
Binary file not shown.
99 changes: 66 additions & 33 deletions src/amazingsort/AmazingSort.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.Scanner;

public class AmazingSort {

// Main loop with the algorithms options
public static void main(String[] args) throws IOException, InterruptedException {
Structures structures = new Structures();
Expand Down Expand Up @@ -39,11 +39,19 @@ public static void main(String[] args) throws IOException, InterruptedException
System.out.println("| 4 - To sort the numbers using merge sort. |");
System.out.println("| 5 - To sort the numbers using quick sort. |");
System.out.println("| 6 - To sort the numbers using radix sort. |");
System.out.println("| 7 - To exit the program. |");
System.out.println("| 7 - To run all sorting algorithms. |");
System.out.println("| 8 - To exit. |");
System.out.println("|----------------------------------------------|");
System.out.print("Option: ");
option = scanner.nextInt();

BubbleSort bubbleSort = new BubbleSort();
InsertionSort insertionSort = new InsertionSort();
MergeSort mergeSort = new MergeSort();
QuickSort quickSort = new QuickSort();
RadixSort radixSort = new RadixSort();
SelectionSort selectionSort = new SelectionSort();

switch(option){
case 0:
System.out.println("Starting numbers generator... ");
Expand All @@ -53,72 +61,97 @@ public static void main(String[] args) throws IOException, InterruptedException

Generator generator = new Generator();
generator.generateNumbers(number);
break;
break;
case 1:
System.out.println("Bubble sort selected... ");
System.out.print("How many elements: ");
number = scanner.nextInt();

BubbleSort bubblesort = new BubbleSort();
bubblesort.sort(structures.fillArray(number));
bubblesort.sort(structures.fillList(number));
// bubblesort.sort(structures.fillStack(number));
break;
bubbleSort.sort(structures.fillArray(number));
bubbleSort.sort(structures.fillList(number));
break;
case 2:
System.out.println("Selection sort selected... ");
System.out.print("How many elements: ");
number = scanner.nextInt();

SelectionSort selectionsort = new SelectionSort();
selectionsort.sort(structures.fillArray(number));
selectionsort.sort(structures.fillList(number));
// selectionsort.sort(structures.fillStack(number));
break;
selectionSort.sort(structures.fillArray(number));
selectionSort.sort(structures.fillList(number));
break;
case 3:
System.out.println("Insertion sort selected... ");
System.out.print("How many elements: ");
number = scanner.nextInt();

InsertionSort insertionsort = new InsertionSort();
insertionsort.sort(structures.fillArray(number));
insertionsort.sort(structures.fillList(number));
// insertionsort.sort(structures.fillStack(number));
break;

insertionSort.sort(structures.fillArray(number));
insertionSort.sort(structures.fillList(number));
break;
case 4:
System.out.println("Merge sort selected... ");
System.out.print("How many elements: ");
number = scanner.nextInt();

MergeSort mergesort = new MergeSort();
mergesort.sort(structures.fillArray(number), 0, number-1);
mergesort.sort(structures.fillList(number), 0, number-1);
// mergesort.sort(structures.fillStack(number), 0, number-1);
break;
mergeSort.sort(structures.fillArray(number), 0, number-1);
mergeSort.sort(structures.fillList(number), 0, number-1);
break;
case 5:
System.out.println("Quick sort selected... ");
System.out.print("How many elements: ");
number = scanner.nextInt();

QuickSort quicksort = new QuickSort();
quicksort.sort(structures.fillArray(number), 0, number-1);
quicksort.sort(structures.fillList(number), 0, number-1);
// quicksort.sort(structures.fillStack(number), 0, number-1);
break;

quickSort.sort(structures.fillArray(number), 0, number-1);
quickSort.sort(structures.fillList(number), 0, number-1);
break;
case 6:
System.out.println("Radix sort selected... ");
System.out.print("How many elements: ");
number = scanner.nextInt();

RadixSort radixSort = new RadixSort();
radixSort.sort(structures.fillArray(number));
radixSort.sort(structures.fillList(number));
break;
case 7:
System.out.println("All sorting algorithms selected... ");
System.out.print("How many elements: ");
number = scanner.nextInt();

System.out.println("Bubble sort started...");
bubbleSort.sort(structures.fillArray(number));
bubbleSort.sort(structures.fillList(number));
System.out.println("Bubble sort end\n");

System.out.println("Selection sort started...");
selectionSort.sort(structures.fillArray(number));
selectionSort.sort(structures.fillList(number));
System.out.println("Selection sort end\n");

System.out.println("Insertion sort started...");
insertionSort.sort(structures.fillArray(number));
insertionSort.sort(structures.fillList(number));
System.out.println("Insertion sort end\n");

System.out.println("Merge sort started...");
mergeSort.sort(structures.fillArray(number), 0, number-1);
mergeSort.sort(structures.fillList(number), 0, number-1);
System.out.println("Merge sort end\n");

System.out.println("Quick sort started...");
quickSort.sort(structures.fillArray(number), 0, number-1);
quickSort.sort(structures.fillList(number), 0, number-1);
System.out.println("Quick sort end\n");

System.out.println("Radix sort started...");
radixSort.sort(structures.fillArray(number));
radixSort.sort(structures.fillList(number));
System.out.println("Radix sort end\n");

break;
case 8:
System.out.println("Exiting the program... ");
break;
break;
default:
System.out.println("ERROR: Invalid option!");
break;
break;
}
}
}
Expand Down

0 comments on commit 45392ef

Please sign in to comment.