Merge pull request #9481 from tapankavasthi/master

Rename array variable name in DNF Partition method
This commit is contained in:
Loredana Crusoveanu 2020-06-15 19:10:05 +03:00 committed by GitHub
commit 004aae2a25
1 changed files with 5 additions and 5 deletions

View File

@ -5,21 +5,21 @@ import static com.baeldung.algorithms.quicksort.SortingUtils.swap;
public class DutchNationalFlagPartioning {
public static Partition partition(int[] a, int begin, int end) {
public static Partition partition(int[] input, int begin, int end) {
int lt = begin, current = begin, gt = end;
int partitioningValue = a[begin];
int partitioningValue = input[begin];
while (current <= gt) {
int compareCurrent = compare(a[current], partitioningValue);
int compareCurrent = compare(input[current], partitioningValue);
switch (compareCurrent) {
case -1:
swap(a, current++, lt++);
swap(input, current++, lt++);
break;
case 0:
current++;
break;
case 1:
swap(a, current, gt--);
swap(input, current, gt--);
break;
}
}