0
$\begingroup$

(Note: cross-listed on stack overflow: https://stackoverflow.com/questions/73362856/looking-for-name-of-a-priority-queue-data-structure-based-on-bit-boundary-bucket)

I'm looking for the name of a data structure. I came up with this idea but suspect it should already be known, and don't know what to search to find it.

This priority queue is based on putting items into buckets based on the position of the largest bit that differs between the largest dequeued priority so far, and the item's priority. Its advantage, over for example a heap, is that it tends to move events in big contiguous groups instead of one by one which gives more memory locality. Note that this priority queue requires that dequeued priorities must increase monotonically. So for example it could be used for an advancing timeline of potential events, but it couldn't be used in all situations.


Suppose priorities are 32 bit integers. Then the priority queue has 33 buckets, each of which is just a vector of prioritized items where the priorities in bucket k differ from the largest dequeued priority at bit position k-1 (with "-1" meaning no difference).

To enqueue an item, append it into bucket std::bit_width(largest_dequeued_priority ^ priority_of_item). If the item's priority is less than largest_dequeued_priority, throw a "not monotonic" exception instead of enqueueing.

To dequeue an item, find the first non-empty bucket. If there is none, fail. If the first empty bucket isn't bucket 0, then advance largest_dequeued_priority to the minimum item priority in that bucket and re-enqueue every item in the bucket to redistribute the items to lower buckets. Now pop an item out of bucket 0 and return it as the result.

enter image description here

$\endgroup$
1

1 Answer 1

0
$\begingroup$

This data structure is called a radix heap.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.