Skip to content

Commit eafc8e9

Browse files
committed
Fix define warning in "temp" variable
1 parent 3009d3b commit eafc8e9

File tree

1 file changed

+8
-3
lines changed
  • algorithm/sorting/quick/basic

1 file changed

+8
-3
lines changed

algorithm/sorting/quick/basic/code.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,37 @@
11
tracer._print('original array = [' + D.join(', ') + ']');
22
tracer._sleep(1000);
33
tracer._pace(500);
4+
45
function quicksort(low, high) {
56
if (low < high) {
67
var p = partition(low, high);
78
quicksort(low, p - 1);
89
quicksort(p + 1, high);
910
}
1011
}
12+
1113
function partition(low, high) {
1214
var pivot = D[high];
1315
tracer._selectSet([low, high]);
1416
var i = low;
17+
var temp;
18+
1519
for (var j = low; j < high; j++) {
1620
if (D[j] <= pivot) {
17-
var temp = D[i];
21+
temp = D[i];
1822
D[i] = D[j];
1923
D[j] = temp;
2024
tracer._notify(i, j);
2125
i++;
2226
}
2327
}
24-
var temp = D[i];
28+
temp = D[i];
2529
D[i] = D[high];
2630
D[high] = temp;
2731
tracer._notify(i, high);
2832
tracer._deselectSet([low, high]);
2933
return i;
3034
}
35+
3136
quicksort(0, D.length - 1);
32-
tracer._print('sorted array = [' + D.join(', ') + ']');
37+
tracer._print('sorted array = [' + D.join(', ') + ']');

0 commit comments

Comments
 (0)