Rename array variable name in DNF Partition method
This commit is contained in:
parent
1bd8a0b90c
commit
b9abcdb3ef
@ -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…
x
Reference in New Issue
Block a user