solidity-examples
solidity-examples copied to clipboard
Bug in function pop()
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