Skip to content

Commit bd99270

Browse files
committed
Includes testHeap.js
1 parent e9c018d commit bd99270

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

testHeap.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
function dispArr(arr) {
2+
for (var i = 0; i < arr.length; ++i) {
3+
process.stdout.write(arr[i] + " ");
4+
if (i % 10 == 9) {
5+
process.stdout.write("\n");
6+
}
7+
}
8+
if (i % 10 != 0) {
9+
process.stdout.write("\n");
10+
}
11+
}
12+
13+
var MAX = 50
14+
var sort = require('./src/sorting/heapsort.js').heapSort;
15+
var values = [];
16+
for (var i = 0; i < MAX; ++i) {
17+
values[i] = Math.floor(Math.random() * MAX+1);
18+
}
19+
20+
console.log('\nBefore: ');
21+
dispArr(values);
22+
console.log('\nAfter: ');
23+
24+
dispArr(sort(values));

0 commit comments

Comments
 (0)