Skip to content

Commit

Permalink
Add comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
trekhleb committed Apr 3, 2018
1 parent 9f8e763 commit 7dd977c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/data-structures/heap/MinHeap.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ export default class MinHeap {
}

heapifyUp() {
// Take last element (last in array or the bottom left in a tree) in
// a heap container and lift him up until we find the parent element
// that is less then the current new one.
let currentIndex = this.heapContainer.length - 1;

while (
Expand All @@ -90,6 +93,8 @@ export default class MinHeap {
}

heapifyDown() {
// Compare the root element to its children and swap root with the smallest
// of children. Do the same for next children after swap.
let currentIndex = 0;
let nextIndex = 0;

Expand Down

0 comments on commit 7dd977c

Please sign in to comment.