Skip to content

Commit 2b1b13f

Browse files
committed
Updated to test heapsort, just needs to display array better
1 parent 0e69f66 commit 2b1b13f

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

test/sorting/heapsort.spec.js

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//var sortTestCase = require('./sort.testcase.js');
2-
var heapSort = require('../../src/sorting/heapsort.js');
2+
//var heapSort = require('../../src/sorting/heapsort.js');
33

44
//sortTestCase(heapSort, 'Heap sort');
55

@@ -8,15 +8,33 @@ var heapSort = require('../../src/sorting/heapsort.js');
88

99
//load('heapsort.js');
1010

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+
24+
1125
var arr = [];
12-
var MAX = 100
26+
var MAX = 100;
27+
28+
var sort = require('./../../src/sorting/heapsort.js').heapSort;
29+
console.log(sort([2, 5, 1, 0, 4])); // [ 0, 1, 2, 4, 5 ]
30+
1331

1432
for(var i = 0; i < MAX; ++i){
15-
arr[i] = Math.floor((Math.random() * 100) + 1);
16-
// print(arr[i]);
33+
arr[i] = Math.floor((Math.random() * 100) + 1);
34+
// print(arr[i]);
1735
}
18-
print(arr);
19-
36+
console.log(arr);
37+
sort(arr);
38+
console.log(arr);
2039

2140

22-
heapSort(arr);

0 commit comments

Comments
 (0)