PacktPublishing / Learning-JavaScript-Data-Structures-and-Algorithms-Third-Edition

Learning JavaScript Data Structures and Algorithms (Third Edition), published by Packt
MIT License
1.05k stars 428 forks source link

Fix heapify error #8

Closed dev-zuo closed 3 years ago

dev-zuo commented 3 years ago

Heapify function error, in MinHeap, heapify([2, 5, 4, 1, 3, 6]) result is [ 2, 1, 4, 5, 3, 6 ], should be [1, 2, 4, 5, 3, 6]

test case

  it('heapify test', () => {
    let arr = [2, 5, 4, 1, 3, 6]
    expect(heap.heapify(arr)).to.deep.equal([1, 2, 4, 5, 3, 6])
  })