|
ADS
Algorithms and Data Structures
|
Files | |
| ArrayQueue.h | |
| The QUEUE of the book [see ADT.h] realized with a circular vector of \( m \) places, the place 0 following the place \( m - 1 \): the queue is in \( n \) consecutive places from the one of its front, \( h \), so that its back is in the place \( ( h + n - 1 ) \bmod m \) and every operation takes \( O( 1 ) \) time; the modulo is a comparison and a subtraction, since the sum is below \( 2 m \), instead of a division. | |
| Dequeue.h | |
| The DEQUEUE (double ended queue) of exercise 4.9, a sequence changed at both ends, which is a STACK when used at one end and a QUEUE when used at both [see ADT.h]: realized with a LIST with pointers, every operation takes \( O( 1 ) \) time. | |
| LinkedQueue.h | |
| A QUEUE [see ADT.h] realized as a singly linked list with a pointer to the first cell, the front, and one to the last cell, the back (exercise 4.10 of the book): enqueue() appends a cell after the back and dequeue() removes the front, both in \( O( 1 ) \) time, and the queue has no bound on its size, unlike the circular vector of ArrayQueue. | |
| MinDeque.h | |
| The double ended queue with the minimum of exercise 3.16 of Morin's book, beyond the book: push_front(), push_back(), pop_front(), pop_back(), size() and min(), all in \( O( 1 ) \) amortized time, on two stacks with the minimum [see MinStack.h] back to back, as the DualArrayDeque of Morin's book [see DualArrayDeque.h]: \( F \) with the front on top and \( B \) with the back on top. | |
| MinQueue.h | |
| The QUEUE with the minimum of exercise 3.15 of Morin's book, beyond the book [see ADT.h]: enqueue(), dequeue(), top(), size() and min(), all in \( O( 1 ) \) amortized time, on two stacks with the minimum [see MinStack.h]: the items enter the stack \( I \) and leave from the stack \( O \), which, when empty, takes all the items of \( I \) in the reverse order, the front on top. | |
| QueueAlgorithms.h | |
| Algorithms that use a QUEUE [see ADT.h] only through its operations, beyond the book: | |
| RandomQueue.h | |
| The random queue of exercise 2.2 of Morin's book, beyond the book: a bag in which push() puts an item and pop() takes one out chosen uniformly at random among those inside, both in \( O( 1 ) \) amortized time. | |
| RealTimeMinDeque.h | |
| The double ended queue with the minimum of exercise 3.16 of Morin's book in \( O( 1 ) \) worst-case time per operation, beyond the book [see MinDeque.h for the amortized one]: push_front(), push_back(), pop_front(), pop_back(), front(), back(), size() and min(), by the global rebuilding of Overmars applied to the two stacks of MinDeque, as Gajewska and Tarjan do for the deques with heap order. | |
| RealTimeMinQueue.h | |
| The QUEUE with the minimum of exercise 3.15 of Morin's book in \( O( 1 ) \) worst-case time per operation, beyond the book [see ADT.h and MinQueue.h for the amortized one]: enqueue(), dequeue(), top(), size() and min(), by the real-time queue of Hood and Melville on arrays with the minimum. | |
| RingDeque.h | |
| A double ended queue on a circular vector that grows, beyond the book: the circular vector of ArrayQueue [see ArrayQueue.h] whose capacity is a power of 2, so that a place is reduced by a mask instead of a division, and that doubles when full, the items moved in order to the front of the new vector (\( O( 1 ) \) amortized time per insertion). | |
| SlidingAggregate.h | |
| The aggregate of a sliding window, beyond the book: a QUEUE of values of the monoid G [see Algebra.h] with aggregate(), the combination \( x_1 \oplus \cdots \oplus x_n \) of its values from the front to the back, in \( O( 1 ) \) time per operation, by the algorithm that the algebra and the policy allow (see The aggregate of a sliding window): | |
| UniqueQueue.h | |
| A QUEUE [see ADT.h] with no duplicates, beyond the book, with one of two policies for an item that is already in the queue: IGNORE_NEW does not enqueue it again, FORGET_OLD removes the old copy and enqueues the item at the back. | |