4 ms·
Ordered queue is a priority queue, which can be implemented using a binary heap. A binary heap can be backed with a simple array, which is more cache friendly t
by ww520 4y ago
Ordered queue is a priority queue, which can be implemented using a binary heap. A binary heap can be backed with a simple array, which is more cache friendly than a linked list. The worst case is O(logN) for insert and delete, only O(1) for peek. It's better than the O(N) insertion sort on the linked list.