Skip to content

init function unnecessarily runs _sortNodeDown on all nodes #665

@ericbstie

Description

@ericbstie

The init function only needs to run _sortNodeDown on all non-leaf nodes, e.g. i < heapArray.length / 2 (see https://stackoverflow.com/a/18742428/8594404). I think this was the intention, because of the Math.floor call; just forgot to divide by 2 ;)

for (let i = Math.floor(this.heapArray.length); i >= 0; --i) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions