Skip to content

Commit 68b43fa

Browse files
Lagt til green highlight når node har svømt til riktig posisjon
1 parent ef3e06b commit 68b43fa

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

Heap/js/MaxHeap.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@ var MaxHeap = /** @class */ (function () {
178178
index = Math.floor((index - 1) / 2);
179179
other = Math.floor((index - 1) / 2);
180180
}
181+
if (index !== 0) {
182+
control.highlightNode(index, "green");
183+
control.highlightNode(other, "green");
184+
control.removeHighlight(index);
185+
control.removeHighlight(other);
186+
}
181187
};
182188
MaxHeap.prototype.getName = function () {
183189
return this.name;

Heap/js/MaxHeap.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,13 @@ class MaxHeap implements IAlgorithm {
207207
index = Math.floor((index - 1) / 2);
208208
other = Math.floor((index - 1) / 2);
209209
}
210+
211+
if (index !== 0) {
212+
control.highlightNode(index, "green");
213+
control.highlightNode(other, "green");
214+
control.removeHighlight(index);
215+
control.removeHighlight(other);
216+
}
210217
}
211218

212219
getName(): string {

0 commit comments

Comments
 (0)