fix algorithmic complexity of heap algorithms