diff --git a/book/content/part02/array.asc b/book/content/part02/array.asc index 3bde2929..25c029ee 100644 --- a/book/content/part02/array.asc +++ b/book/content/part02/array.asc @@ -73,7 +73,7 @@ Here's an example: [source, javascript] ---- const array = [2, 5, 1]; -array.unshift(0); // ↪️ 8 +array.unshift(0); // ↪️ 4 console.log(array); // [ 0, 2, 5, 1 ] array.unshift(-2, -1); // ↪️ 6 console.log(array); // [ -2, -1, 0, 2, 5, 1 ] diff --git a/src/data-structures/heaps/heap.js b/src/data-structures/heaps/heap.js index 54863c39..537894ee 100644 --- a/src/data-structures/heaps/heap.js +++ b/src/data-structures/heaps/heap.js @@ -59,7 +59,7 @@ class Heap { */ bubbleUp() { let index = this.size - 1; - const parent = (i) => Math.ceil(i / 2 - 1); + const parent = (i) => Math.ceil(i / 2) - 1; while (parent(index) >= 0 && this.comparator(parent(index), index) > 0) { this.swap(parent(index), index); index = parent(index);