-
Notifications
You must be signed in to change notification settings - Fork 18
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
const heap = new Heap((a, b) => a - b, [3, 1, 4])
heap.insert(2)
console.log(heap.toArray())
// Expected result: 1, 2, 4, 3; Actual result: 3, 1, 4, 2
const heap1 = new Heap((a, b) => a - b, [3, 1, 4])
heap1.insert(0)
console.log(heap1.toArray())
// Expected results: 0, 1, 4, 3; Actual results: 0, 3, 4, 1
const heap2 = new MinHeap()
;[3, 1, 4, 1, 5].forEach((n) => heap2.insert(n))
for (const num of heap2) {
console.log(num)
}
// The expected results are 1, 1, 4, 3, and 5. Actual result: 1, 1, 3, 4, 5
- Initialization did not perform heapification, and the insertion operation caused some values to float up.
- The heapification of the insertion operation was incorrect and did not match the predicted value.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Status
Done