forked from loiane/javascript-datastructures-algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheap.spec.ts
51 lines (38 loc) · 969 Bytes
/
heap.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import 'mocha';
// import { expect } from 'chai';
import { MinHeap } from '../../../src/ts/index';
import { MaxHeap } from '../../../src/ts/data-structures/heap';
import heapSort from '../../../src/ts/sorting/heap-sort';
describe('Heap', () => {
let heap: MinHeap<number>;
beforeEach(() => {
heap = new MinHeap<number>();
});
it('starts empty', () => {
});
it('inserts elements in the AVLTree', () => {
heap.insert(3);
heap.insert(2);
heap.insert(1);
heap.insert(4);
heap.extract();
heap.extract();
heap.extract();
heap.extract();
heap.isEmpty();
const maxHeap = new MaxHeap<number>();
maxHeap.insert(3);
maxHeap.insert(2);
maxHeap.insert(1);
maxHeap.insert(4);
maxHeap.extract();
maxHeap.extract();
maxHeap.extract();
maxHeap.extract();
maxHeap.isEmpty();
});
it('Heap Sort', () => {
const array = [3, 2, 5, 6, 1, 7, 8, 9];
heapSort(array);
});
});