ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
tree Directory Reference

Files

 
ArrayBinaryTree.h
 A binary tree in a positional vector, beyond the book: the root in the place 0, the children of the place \( i \) in \( 2 i + 1 \) and \( 2 i + 2 \), its parent in \( \lfloor ( i - 1 ) / 2 \rfloor \) [see dary_child()], an empty place where no node is.
 
AVLTree.h
 The AVL tree of Adelson-Velsky and Landis, beyond the book [see SearchTree.h for the Red-Black tree of chapter 6]: a binary search tree whose every node has subtrees of heights differing by at most 1, so that its height is below \( 1.4405 \log_2( n + 2 ) \), a little more balanced than a Red-Black tree (whose bound is \( 2 \log_2( n + 1 ) \)), at the price of more rotations on the updates.
 
BinaryTree.h
 The binary TREE of the book: an ordered tree where each node has at most two children, told apart as the left and the right one, realized with pointers to the parent and to the two children.
 
BinaryTreeAlgorithms.h
 The classic problems on binary trees and on binary search trees, written once for any representation of the nodes: a node is reached by a pointer, nil is nullptr, and its links and its key are read either by the member functions left(), right(), parent() and read() of BinaryTree [see BinaryTree.h] or by the fields left, right, parent and key of a plain struct, as in the pseudocode of the book.
 
BPlusTree.h
 The B+-tree of order \( m \) of the reality check of chapter 6, the search tree of the file systems and of the databases, whose nodes are pages of the secondary memory.
 
BTree.h
 The B-tree of Bayer and McCreight, beyond the book [see BPlusTree.h for the B+-tree of chapter 6, which has no removal]: a search tree whose nodes hold from \( t - 1 \) to \( 2 t - 1 \) keys (the root from 1), \( t \) the minimum degree, a node of \( j \) keys having \( j + 1 \) children, and all the leaves at the same depth, so that the height is at most \( \log_t( ( n + 1 ) / 2 ) \) and a node fills a block of the disk.
 
BTreeMap.h
 An ordered map on a B+-tree in main memory, beyond the book: the engineered ordered DICTIONARY of ADS [see ADT.h], the one that the benchmark of the ordered dictionaries compares with std::map, absl::btree_map and tlx::btree_map, while BPlusTree [see BPlusTree.h] stays the tree of section 6.3 and BTree [see BTree.h] that of Bayer and McCreight.
 
ChildListTree.h
 An ordered tree realized with lists of children, beyond the book: the nodes in a vector, each with its value, the place of its parent and the List [see List.h] of the places of its children, in their order.
 
CursorBinaryTree.h
 A binary tree with cursors, beyond the book: the nodes in a vector, each with its value and the places of its parent and of its two children, NIL if missing, so that the links are indices instead of pointers and the tree can be copied, saved or moved as a whole.
 
CursorTree.h
 An ordered tree with cursors, beyond the book: the nodes in a vector, each with its value and the places of its parent, of its first child and of its next sibling, NIL if missing, as the Tree with pointers [see Tree.h] but with indices.
 
ExpressionTree.h
 The tree of an arithmetic expression (the parse tree), beyond the book: a binary tree [see BinaryTree.h] whose leaves are the operands, numbers or names of variables, and whose internal nodes are the binary operators +, -, *, / and ^ (the power), the left subtree being the left operand.
 
FingerTreap.h
 The treap with finger search of exercise 7.9 of Morin, beyond the book: a treap [see Treap.h] whose nodes keep their parent, the size of their subtree and its smallest and largest node, so that a search may start from any node \( u \) rather than from the root: it climbs to the first ancestor \( w \) whose subtree spans the key, \( w.\mathit{min} \le k \le w.\mathit{max} \), and goes down from it as usual.
 
HashedTreap.h
 The treap that stores no priorities (exercise 7.6 of Morin), beyond the book: the treap of Seidel and Aragon [see Treap.h] whose priority of a node is the simple tabulation hash of its address [see RandomHashing.h], computed when needed, so that a node keeps only its pair and its two links.
 
HeapByInsertion.h
 The max-heap on a vector built by insertions, the construction of Williams, beside the bottom-up one of Floyd [see Heapsort.h].
 
JoinAlgorithms.h
 The balanced binary search trees whose only balancing operation is join, beyond the book, and the operations on ordered sets and maps built on it, sequential and parallel.
 
JoinTree.h
 The binary search trees balanced by join alone, and the augmented maps, beyond the book: JoinTree< K , V , B , G > is a DICTIONARY [see ADT.h] of keys K and values V whose only balancing operation is the join of the scheme B [see JoinAlgorithms.h], AVLBalance, RedBlackBalance, WeightBalance or TreapBalance, so that the insertions and the removals are a split or a descent followed by joins, and the bulk operations of Joinable (union, intersection, difference, batches of insertions and of removals, filter, map and reduce, extraction of a range) are those of the four schemes alike.
 
LeftLeaningRedBlackTree.h
 The RedBlackTree of Morin (chapter 9), a left-leaning red-black tree that simulates a 2-4 tree, beyond the book: a binary search tree whose nodes are red or black with the black-height property (every path from a node down to a nil crosses the same number of black nodes), the no-red-edge property (a red node has no red child) and the left-leaning property (if the left child of a node is black, so is the right one); nil and the root are black.
 
LinkCutTree.h
 The link-cut trees of Sleator and Tarjan, beyond the book: a forest of rooted trees on the nodes \( 0 , \ldots , n - 1 \) that changes by link() and cut() of an edge, and answers connected(), findRoot(), the lowest common ancestor lca() and the aggregate of the values of the nodes on the path between two nodes, aggregate(), each in \( O( \log n ) \) amortized time (see Dynamic trees).
 
MaterializedAggregate.h
 The aggregate of a structure kept by its events, beyond the book: MaterializedAggregate< G , Period > is an observer [see Modification.h] of a dictionary whose handles are its keys (as those of JoinTree), which keeps the combination by the commutative monoid G [see Augmentation in JoinTree.h] of the values \( \mathrm{from}( k , v ) \) of its pairs, from the events Inserted, Erased, Assigned, Cleared and Rebuilt, and gives it by value().
 
MeasuredSearchTree.h
 The binary search tree of Morin whose nodes keep the size, the depth and the height of their subtree (exercise 6.19 of Morin), beyond the book: a DICTIONARY [see ADT.h] with the find(x) of an SSet (lowerBound()) and the getLE(x) of exercise 6.14, whose insertions and removals keep the three measures of every node exact for a constant factor on the plain tree, \( O( h ) \) time.
 
ParentTree.h
 The tree as a vector of parents: the nodes are \( 0 , \ldots , n - 1 \), and \( p[ i ] \) is the parent of \( i \), or -1 if \( i \) is a root.
 
PartialRebuildingTree.h
 Three trees balanced by partial rebuilding, from exercises 8.8 to 8.10 of Morin, beyond the book: binary search trees whose insertions and removals are those of the plain tree, followed by the rebuilding of the subtree of the highest node of the path that a rule selects into a perfectly balanced one [see ScapegoatTree.h for the rebuild].
 
PreorderArrayTree.h
 An ordered tree in a vector in preorder, beyond the book: the place \( i \) holds the value of the \( i \)-th node of the previsit and the place of its parent, NIL for the root in the place 0.
 
RandomizedSearchTree.h
 The randomized binary search tree of Martínez and Roura (exercise 7.14 of Morin), beyond the book: a binary search tree that stores no priorities but the size of each subtree, and stays a random binary search tree, i.e., of the shape that the insertions of its keys in a uniformly random order give, whatever the order of the operations; the expected depth of a node is \( O( \log n ) \), as in a treap [see Treap.h], and the sizes give the access by rank for free (select(), rank()).
 
ScapegoatTree.h
 The scapegoat tree of Galperin and Rivest, the general balanced tree of Andersson (section 8.1 of Morin), beyond the book: a binary search tree with no balance information in its nodes, whose height stays at most \( \log_b q \), \( q \) an upper bound on the number of keys that satisfies \( q / 2 \le n \le q \) and \( 1 < b < 2 \) a parameter (\( b = 3 / 2 \) in Morin, \( b = 1 / \alpha \) in Galperin and Rivest), by rebuilding subtrees into perfectly balanced ones.
 
SearchTree.h
 The binary search tree (ABR) and the Red-Black tree of the book, as a DICTIONARY [see ADT.h] from keys to values.
 
SplayTree.h
 The splay tree of Sleator and Tarjan, beyond the book: a binary search tree with no balance information, where each access moves the node accessed to the root by rotations in pairs (zig-zig and zig-zag), which roughly halve the depth of the nodes on its path; any sequence of \( m \) operations on \( n \) keys takes \( O( ( m + n ) \log n ) \) time, i.e., \( O( \log n ) \) amortized each, and the keys accessed often stay near the root (the static optimality and the working set theorems).
 
ThreadedTree.h
 The threaded binary search tree of Perlis and Thornton, beyond the book: a missing left child is replaced by a link (a thread) to the predecessor in symmetric order, and a missing right child by a thread to the successor, a bit of each node telling a child from a thread; the symmetric visit then needs neither a stack nor the recursion, the successor of a node being its right thread or the leftmost node of its right subtree (Algorithm S of Knuth, section 2.3.1), in \( O( 1 ) \) amortized time each.
 
Treap.h
 The treap of Seidel and Aragon, beyond the book: a binary search tree on the keys that is also a heap on random priorities given to the keys when they are inserted, so that its shape is that of a binary search tree built by inserting the keys in a random order, whatever the order of the operations; the expected depth of a node is \( O( \log n ) \), and an insertion or a removal takes \( O( \log n ) \) expected time and makes fewer than 2 rotations on average.
 
Tree.h
 The ordered TREE of the book, realized with pointers to the parent, to the first child and to the next sibling, and its visits.