insertion and deletion in an array using the heap method
//Insertion in a max heap
function insertionInAHeap(arr, key){
arr.push(key)
let firstNonLeafNodeIdx = Math.floor((arr.length) / 2) - 1
for(let i = firstNonLeafNodeIdx; i >= 0; i--){
heapify(arr, i)
}
}
//Deletion in a max heap
functio...
kamilapreetisamuel.hashnode.dev1 min read