File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed
Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change 33class CombSort
44{
55 // To find gap between elements
6- int getNextGap (int gap )
6+ static int getNextGap (int gap )
77 {
88 // Shrink gap by Shrink factor
99 gap = (gap *10 )/13 ;
10- if (gap < 1 )
11- return 1 ;
12- return gap ;
10+ gap = (gap < 1 ) ? 1 : gap ;
1311 }
1412
1513 // Function to sort arr[] using Comb Sort
16- void sort (int arr [])
14+ static void sort (int arr [])
1715 {
1816 int n = arr .length ;
1917
@@ -24,7 +22,7 @@ void sort(int arr[])
2422 boolean swapped = true ;
2523
2624 // Keep running while gap is more than 1 and last iteration caused a swap
27- while (gap != 1 || swapped == true )
25+ while (gap != 1 || swapped )
2826 {
2927 // Find next gap
3028 gap = getNextGap (gap );
@@ -57,8 +55,8 @@ public static void main(String args[])
5755 ob .sort (arr );
5856
5957 System .out .println ("sorted array" );
60- for (int i =0 ; i <arr .length ; ++i )
58+ for (int i =0 ; i <arr .length ; ++i ) {
6159 System .out .print (arr [i ] + " " );
62-
60+ }
6361 }
6462}
You can’t perform that action at this time.
0 commit comments