MCPcopy Index your code
hub / github.com/TheAlgorithms/JavaScript / insert

Method insert

Data-Structures/Heap/BinaryHeap.js:32–35  ·  view source on GitHub ↗

* Inserts a new value into the heap. * @param {*} value - The value to be inserted into the heap.

(value)

Source from the content-addressed store, hash-verified

30 * @param {*} value - The value to be inserted into the heap.
31 */
32 insert(value) {
33 this.heap.push(value)
34 this.#bubbleUp(this.heap.length - 1)
35 }
36
37 /**
38 * Returns the number of elements in the heap.

Callers 2

BinaryHeap.test.jsFile · 0.45

Calls 2

#bubbleUpMethod · 0.95
pushMethod · 0.45

Tested by

no test coverage detected