Radix heap

from Wikipedia, the free encyclopedia

A radix heap is a data structure for realizing the operations of a priority queue . This can be used to manage a number of elements, each of which is assigned a key. The runtime of the operations depends on the difference between the largest and smallest key or is constant. The data structure consists mainly of a series of buckets (of English. Bucket " bucket ") whose size exponentially increases.

requirements

  1. all keys are natural numbers
  2. Max. Key - min. Key C for a fixed C.
  3. Monotony of extractMin , d. H. the values ​​returned by successive extractMin calls are monotonically increasing .

Description of the data structure

The three most important fields are:

  1. the size , with 0 as the lowest index; saves the buckets
  2. the size , with 0 as the lowest index; saves the (lower) bounds of the buckets
  3. , holds the bucket in which it is stored for each element in the heap

RadixHeap1.png

In the sketch above, the data structure is sketched again. It should now be noted that the following invariants must always apply:

  1. Keys in : the keys in are limited upwards and downwards by the values ​​in and .
  2. and for : the sizes of the buckets increase exponentially.

Note the exponential growth of the bounds (and thus of the area that a bucket holds). This results in the logarithmic dependence of the field sizes on the value , the maximum difference between two key values .

Operations

During the initialization , empty buckets are created and the lower bounds are calculated (according to invariant 2); Term .

When insert a new element is gone linearly from right to left through the buckets and the new element is stored in the linkesten bucket, so that: . Term .

The field is now required for decreaseKey . From the now known bucket, analogous to the insert operation, it is now iterated to the left after decrementing the key value (it must also be checked that the invariants are adhered to); Term (amortized).

The extractMin operation returns an item from the bucket and removes it. If the bucket is not yet empty, the operation is finished. If, however, it is now empty, the next larger, non-empty bucket is searched for, its smallest element is found and set to k (the monotony is required for this). Then, according to the invariants, the bucket limits are redefined and the elements are distributed to the newly created buckets; Term (amortized).

If displayed, the field must also be updated.

literature