Skip to content

Latest commit

 

History

History
 
 

binary_heaps_exercise

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Binary Heaps Exercise

For this exercise you must get the tests to pass.

Part I

Given the following constructor function

function MaxBinaryHeap(val){
    this.values = [];
}

insert

Implement the insert function on the MaxBinaryHeap.prototype: This function should insert a node in a binary heap. Make sure to re-order the heap after insertion if necessary

Part II

Implement a function called checkMaxHeap. It should check if an array is a valid Max Heap and return true or false.

Given an array of numbers, implement a function called maxHeapify which converts an array of numbers into a max-heap. Note that this function assumes a correct implentation of checkMaxHeap.

Bonus

Implement the remove function on the MaxBinaryHeap.prototype This function should remove the root node in a binary heap. Make sure to re-order the heap after removal if necessary