Skip to content

Commit

Permalink
Update SortingAlgorithms1.java
Browse files Browse the repository at this point in the history
Organised the main method
  • Loading branch information
Ashirz authored Dec 18, 2024
1 parent 24037c1 commit 4a9b834
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/Algorithms/SortingAlgorithms1.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,16 @@ public class SortingAlgorithms1 {
public static void main(String[] args) {
int array[] = { 5, 8, 9, 1, 2, 6, 4 };

sort(array, 0, array.length - 1);
sort(array, 0, array.length - 1);
System.out.println("After Quick Sort:");
printArray(array);

System.out.println("Implementing Quick sort");
for (int i : array)
System.out.print(i);
System.out.println();

divide(array);

System.out.println("Implementing Merge sort");
for (int i : array)
System.out.print(i);
System.out.println();
// Reset the array for subsequent sorts
array = new int[] { 5, 8, 9, 1, 2, 6, 4 };

mergeSort(array);
System.out.println("After Merge Sort:");
printArray(array);
}

// Merge sort methods divide & conquer
Expand Down

0 comments on commit 4a9b834

Please sign in to comment.