Merge pull request #9481 from tapankavasthi/master
Rename array variable name in DNF Partition method
This commit is contained in:
commit
004aae2a25
|
@ -5,21 +5,21 @@ import static com.baeldung.algorithms.quicksort.SortingUtils.swap;
|
||||||
|
|
||||||
public class DutchNationalFlagPartioning {
|
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 lt = begin, current = begin, gt = end;
|
||||||
int partitioningValue = a[begin];
|
int partitioningValue = input[begin];
|
||||||
|
|
||||||
while (current <= gt) {
|
while (current <= gt) {
|
||||||
int compareCurrent = compare(a[current], partitioningValue);
|
int compareCurrent = compare(input[current], partitioningValue);
|
||||||
switch (compareCurrent) {
|
switch (compareCurrent) {
|
||||||
case -1:
|
case -1:
|
||||||
swap(a, current++, lt++);
|
swap(input, current++, lt++);
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
current++;
|
current++;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
swap(a, current, gt--);
|
swap(input, current, gt--);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue