Mixture of a minheap and a hashtable for some cs class