Skip to content

Instantly share code, notes, and snippets.

@naveen17797
Last active July 9, 2020 00:17
Show Gist options
  • Save naveen17797/7ca4683ff69daeaa870a685a5d7cf10b to your computer and use it in GitHub Desktop.
Save naveen17797/7ca4683ff69daeaa870a685a5d7cf10b to your computer and use it in GitHub Desktop.
class Heap {
constructor() {
this.heap = []
}
getElement(i) {
return heap[i] !== undefined ? heap[i] : false
}
left(i) {
let index = ( 2 * i ) + 1
return getElement(index)
}
right(i) {
let index = ( 2 * i ) + 2
return getElement(index)
}
parent(i) {
let index = Math.floor(i/2)
return getElement(index)
}
insert(value) {
// 1. Find the insertion point.
}
heapify(index) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment