Skip to content

Commit e9c018d

Browse files
committed
Updated to have working display and use of heapsort
1 parent 2b1b13f commit e9c018d

File tree

1 file changed

+23
-26
lines changed

1 file changed

+23
-26
lines changed

test/sorting/heapsort.spec.js

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,3 @@
1-
//var sortTestCase = require('./sort.testcase.js');
2-
//var heapSort = require('../../src/sorting/heapsort.js');
3-
4-
//sortTestCase(heapSort, 'Heap sort');
5-
6-
7-
8-
9-
//load('heapsort.js');
10-
11-
//var arr = [];
12-
//var MAX = 100
13-
14-
//for(var i = 0; i < MAX; ++i){
15-
// arr[i] = Math.floor((Math.random() * 100) + 1);
16-
// print(arr[i]);
17-
//}
18-
//print(arr);
19-
20-
21-
22-
//heapSort(arr);
23-
241

252
var arr = [];
263
var MAX = 100;
@@ -33,8 +10,28 @@ for(var i = 0; i < MAX; ++i){
3310
arr[i] = Math.floor((Math.random() * 100) + 1);
3411
// print(arr[i]);
3512
}
36-
console.log(arr);
37-
sort(arr);
38-
console.log(arr);
3913

14+
function dispArr(arr) {
15+
for (var i = 0; i < arr.length; ++i) {
16+
process.stdout.write(arr[i] + " ");
17+
if (i % 10 == 9) {
18+
process.stdout.write("\n");
19+
}
20+
}
21+
if (i % 10 != 0) {
22+
process.stdout.write("\n");
23+
}
24+
}
25+
26+
27+
28+
29+
30+
31+
//console.log(arr);
32+
dispArr(arr);
33+
sort(arr);
34+
console.log("");
35+
//console.log(arr);
36+
dispArr(arr);
4037

0 commit comments

Comments
 (0)