• + 0 comments

    Build a minHeap using an array. This is all a priority queue is. A heap is fast because it takes O(1) time to access the min and O(logn) time to traverse the tree. A normal queue takes O(n) time to traverse it and O(n) to access the min.