Last active
July 9, 2020 00:17
-
-
Save naveen17797/7ca4683ff69daeaa870a685a5d7cf10b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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