Skip to content

Commit 4a9b834

Browse files
authored
Update SortingAlgorithms1.java
Organised the main method
1 parent 24037c1 commit 4a9b834

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

src/Algorithms/SortingAlgorithms1.java

+8-12
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,16 @@ public class SortingAlgorithms1 {
55
public static void main(String[] args) {
66
int array[] = { 5, 8, 9, 1, 2, 6, 4 };
77

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

10-
System.out.println("Implementing Quick sort");
11-
for (int i : array)
12-
System.out.print(i);
13-
System.out.println();
14-
15-
divide(array);
16-
17-
System.out.println("Implementing Merge sort");
18-
for (int i : array)
19-
System.out.print(i);
20-
System.out.println();
12+
// Reset the array for subsequent sorts
13+
array = new int[] { 5, 8, 9, 1, 2, 6, 4 };
2114

15+
mergeSort(array);
16+
System.out.println("After Merge Sort:");
17+
printArray(array);
2218
}
2319

2420
// Merge sort methods divide & conquer

0 commit comments

Comments
 (0)