We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ea03c38 commit d168bf0Copy full SHA for d168bf0
src/data_structures/priority_queue.js
@@ -55,8 +55,9 @@ class PriorityQueue {
55
*/
56
_fixBottomHeap(idx) {
57
let changeIdx = idx;
58
- let childIdx = (idx << 1) + 1;
59
- while (childIdx <= (idx << 1) + 2) {
+ let childIdx = idx * 2 + 1;
+ let rightChildIdx = idx * 2 + 2;
60
+ while (childIdx <= rightChildIdx) {
61
if (childIdx < this._size && this.comparison(
62
this._priorityHeap[childIdx], this._priorityHeap[changeIdx])) {
63
changeIdx = childIdx;
0 commit comments