11class QuickSort {
2+ //main method
23 public static void main (String args []) {
34 int arr [] = { 101 , 37 , 68 , 29 , 11 , 5 };
4- System .out .println ("before sorting the array" );
5+ System .out .println ("before sorting array" );
56 for (int element : arr ) {
67 System .out .print (element + " " );
78 }
@@ -10,7 +11,7 @@ public static void main(String args[]) {
1011 QuickSort ob = new QuickSort ();
1112 ob .sort (arr , 0 , n - 1 );
1213
13- System .out .println ("after sorting the array" );
14+ System .out .println ("after sorting array" );
1415 printArray (arr );
1516 }
1617
@@ -31,20 +32,20 @@ int partition(int arr[], int lowIndex, int highIndex) {
3132 arr [highIndex ] = temp ;
3233 return i + 1 ;
3334 }
34-
35+ // method to sort array
3536 void sort (int arr [], int lowIndex , int highIndex ) {
3637 if (lowIndex < highIndex ) {
3738 int pi = partition (arr , lowIndex , highIndex );
3839 sort (arr , lowIndex , pi - 1 );
3940 sort (arr , pi + 1 , highIndex );
4041 }
4142 }
42-
43+ // method to print array
4344 static void printArray (int arr []) {
4445 int n = arr .length ;
4546
4647 for (int i = 0 ; i < n ; ++i )
4748 System .out .print (arr [i ] + " " );
4849 System .out .println ();
4950 }
50- }
51+ }
0 commit comments