Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c20acfb

Browse files
Merge pull request amejiarosario#114 from Balaji1202/patch-1
fix(heap.js): makes it easier to reason and avoids negative zero `-0` case.
2 parents 41205d6 + cde6e8a commit c20acfb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

‎src/data-structures/heaps/heap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class Heap {
5959
*/
6060
bubbleUp() {
6161
let index = this.size - 1;
62-
const parent = (i) => Math.ceil(i / 2 - 1);
62+
const parent = (i) => Math.ceil(i / 2) - 1;
6363
while (parent(index) >= 0 && this.comparator(parent(index), index) > 0) {
6464
this.swap(parent(index), index);
6565
index = parent(index);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /