Added heap algorithm