Maxheap and minheap implementations of priority queues