From 1c515854c778bf239f9ba11fa811d9c5a95c69f1 Mon Sep 17 00:00:00 2001 From: Divyansh Date: Tue, 24 Nov 2020 13:01:32 +0530 Subject: [PATCH] bug fixes --- .vscode/settings.json | 3 +++ src/heap/index.js | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 9d4c5a4..c7ee51c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,7 @@ { "eslint.enable": true, "eslint.autoFixOnSave": true, + "editor.codeActionsOnSave": { + "source.fixAll.eslint": true + }, } \ No newline at end of file diff --git a/src/heap/index.js b/src/heap/index.js index f8ebb5b..a99b1ad 100644 --- a/src/heap/index.js +++ b/src/heap/index.js @@ -40,7 +40,7 @@ class Heap { delete (data) { let index = 0 - if (data) { + if (data !== undefined) { index = find(this.array, data) } @@ -51,7 +51,8 @@ class Heap { this.heapifyDown(index) } - heapifyDown (index) { + heapifyDown (i) { + let index = i while (this.hasLeftChild(index)) { let smallerChildIndex = this.getLeftChildIndex(index) if (this.hasRightChild(index) &&