ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
TreePriorityQueue.h File Reference

The PRIORITYQUEUE [see PriorityQueue.h] on a tree. More...

#include "ADS/Contract.h"
#include "ADS/Iterators.h"
#include "ADS/priority/PriorityQueue.h"
#include "ADS/tree/SearchTree.h"
#include <concepts>
#include <cstddef>
#include <utility>
#include <vector>
#include "ADS/priority/impl/TreePriorityQueue.tpp"

Go to the source code of this file.

Classes

class  ADS::TreePriorityQueue< T, P >
 a priority queue on a Red-Black tree of the pairs of a priority and of a number of insertion More...

Namespaces

namespace  ADS

Detailed description

The PRIORITYQUEUE [see PriorityQueue.h] on a tree.

TreePriorityQueue is a Red-Black tree of the pairs \( ( p , i ) \) of a priority and of a number of insertion (section 10.1.2), the number making the keys distinct: the minimum is the leftmost node, and every operation takes \( O( \log n ) \) time, since the height of the tree is \( O( \log n ) \) [see SearchTree.h]. The handle of an item is its number of insertion, and a vector of the priorities by number gives the key under which decrease() finds it.

The contracts [see Contract.h]: min() and deleteMin() need a queue that is not empty, decrease() the handle of an item still in the queue and a priority not larger than its own; the invariant is that each item of the tree has the priority recorded for its handle. The operations are defined in TreePriorityQueue.tpp.

See also
A. Montresor, Algoritmi e Strutture Dati, 2025, section 10.1.2, https://algoritmicamente.it/materiali/libro/capitoli/cap10.pdf
Author
Donato Meoli
Dipartimento di Informatica
Università di Pisa