45#include <gtest/gtest.h>
66 std::vector<std::unique_ptr<Node>>
nodes;
68 Node * make(
const int key)
70 nodes.push_back(std::make_unique<Node>(key));
71 return nodes.back().get();
77 constexpr int level_order[] = {8, 4, 12, 2, 6, 10, 14, 1, 3, 5, 7, 9, 11, 13, 15};
80 constexpr int leaves[] = {1, 3, 5, 7, 9, 11, 13, 15};
83TEST(TreePathCapacity, AvlTreeAsTallAsMaxHeight)
86 static_assert(Tree::Node::MaxHeight == 4);
91 ASSERT_NE(tree.
insert(pool.make(key)),
nullptr);
93 ASSERT_TRUE(tree.verify());
95 for (
const int key : leaves)
97 ASSERT_NE(tree.
remove(key),
nullptr) <<
"key " << key;
98 ASSERT_TRUE(tree.verify());
100 EXPECT_EQ(
size(tree.getRoot()), 7u);
103TEST(TreePathCapacity, RbTreeAsTallAsMaxHeight)
106 static_assert(Tree::Node::MaxHeight == 4);
111 ASSERT_NE(tree.
insert(pool.make(key)),
nullptr);
113 ASSERT_TRUE(tree.verify());
115 for (
const int key : leaves)
117 ASSERT_NE(tree.
remove(key),
nullptr) <<
"key " << key;
118 ASSERT_TRUE(tree.verify());
120 EXPECT_EQ(tree.size(), 7u);
WeightedDigraph::Node Node
AVL balanced binary search tree.
Red-black binary search tree implementation (bottom-up).
Data portion of an AVL tree node.
Conjunto de nodos a reusarse.
QuadTree - Hierarchical spatial index for 2D points.
void remove(const Point &p)
Remove a point from the tree.
Point * insert(Node *&r, const Point &p)
Recursive insert helper.
Data portion of a Red-Black tree node.
DynArray< Graph::Node * > nodes
#define DECLARE_BINNODE_SENTINEL(Name, height, Control_Data)
Specify tree node for a binary tree.
#define DECLARE_BINNODE(Name, height, Control_Data)
Specify tree node for a binary tree.
size_t computeHeightRec(Node *root) noexcept
Compute the height of root
Main namespace for Aleph-w library functions.
size_t size(Node *root) noexcept
See compute_cardinality_rec(Node * root).
AVL tree implementation (height-balanced BST).
Utility functions for binary tree operations.
Red-Black tree implementation (bottom-up balancing).
void level_order(int v[], int n)
Write level-order traversal for LaTeX output.