implementation of min-heap