Skip to content

Bug in function pop() #6

@lukehutch

Description

@lukehutch

The left child of node i has index 2 * i + 1, and the left child has index 2 * i + 2. You are using 2 * i and 2 * i + 1 respectively, which (for a full implementation of min-heapify) leads to an infinite loop if you are trying to min-heapify starting at index 0, since 2 * 0 == 0.

https://github.com/chriseth/solidity-examples/blob/master/heap.sol#L54

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