|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Treap node definition with BST key and heap priority. More...
Go to the source code of this file.
Classes | |
| class | Aleph::TreapNode_Data |
| Data portion of a treap node. More... | |
| class | Aleph::TreapNode< Key > |
| Declare TreapNode type with 80-byte pool allocation. More... | |
| class | Aleph::TreapNodeVtl< Key > |
Namespaces | |
| namespace | Aleph |
| Main namespace for Aleph-w library functions. | |
Functions | |
| template<class Node > | |
| unsigned long & | Aleph::PRIO (Node *p) noexcept |
| Access the priority of a treap node. | |
| template<class Node > | |
| bool | Aleph::is_treap (Node *root) noexcept |
| Validate that a tree satisfies treap (heap) property. | |
Variables | |
| const long | Aleph::Max_Priority = ULONG_MAX |
| Maximum priority value (used for sentinel/leaves) | |
| const long | Aleph::Min_Priority = 0 |
| Minimum priority value. | |
Treap node definition with BST key and heap priority.
This file defines the TreapNode structure for treaps - a randomized data structure combining binary search tree and heap properties.
A treap maintains two invariants simultaneously:
The random priorities ensure expected O(log n) height regardless of insertion order.
| Feature | Treap | AVL/RB |
|---|---|---|
| Balance | Probabilistic | Guaranteed |
| Code complexity | Simple | Complex |
| Expected height | 1.99 log n | 1.44 log n |
| Worst case | O(n) unlikely | O(log n) |
Definition in file treapNode.H.