mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-12-25 22:46:20 +08:00
Add Heap.
This commit is contained in:
parent
09100eab44
commit
5e75378280
@ -34,20 +34,24 @@ describe('MinHeap', () => {
|
||||
minHeap.add(5);
|
||||
minHeap.add(3);
|
||||
minHeap.add(10);
|
||||
minHeap.add(11);
|
||||
minHeap.add(1);
|
||||
|
||||
expect(minHeap.toString()).toBe('1,3,10,5');
|
||||
expect(minHeap.toString()).toBe('1,3,10,11,5');
|
||||
|
||||
expect(minHeap.poll()).toBe(1);
|
||||
expect(minHeap.toString()).toBe('3,5,10');
|
||||
expect(minHeap.toString()).toBe('3,5,10,11');
|
||||
|
||||
expect(minHeap.poll()).toBe(3);
|
||||
expect(minHeap.toString()).toBe('5,10');
|
||||
expect(minHeap.toString()).toBe('5,11,10');
|
||||
|
||||
expect(minHeap.poll()).toBe(5);
|
||||
expect(minHeap.toString()).toBe('10');
|
||||
expect(minHeap.toString()).toBe('10,11');
|
||||
|
||||
expect(minHeap.poll()).toBe(10);
|
||||
expect(minHeap.toString()).toBe('11');
|
||||
|
||||
expect(minHeap.poll()).toBe(11);
|
||||
expect(minHeap.toString()).toBe('');
|
||||
|
||||
expect(minHeap.poll()).toBeNull();
|
||||
|
Loading…
Reference in New Issue
Block a user