34# include <gsl/gsl_rng.h>
49 cout << node->get_key() <<
" ";
57 try { n =
stoi(
argv[1]); }
catch (...) { n = 10; }
62 cerr <<
"n must be positive" <<
endl;
66 unsigned int seed = 0;
82 cout <<
"Inserting " << n <<
" random values in tree ...\n";
84 for (
int i = 0; i < n; i++)
105 cout <<
"Sorting keys array" <<
endl;
107 for (
int i = 0; i <
keys.size(); ++i)
108 cout <<
keys(i) <<
" ";
112 cout <<
"inorden traversal prio" <<
endl;
116 cout <<
"Testing select" <<
endl;
118 for (
int i = 0; i < n; i++)
121 cout << node->get_key() <<
" ";
129 cout <<
"testing random positions" <<
endl;
130 for (
int i = 0; i < n; ++i)
133 std::pair<int, Splay_Tree_Rk<int>::Node*> pos =
139 cout << idx <<
"<-->" << pos.first <<
endl
140 <<
keys(idx) <<
"<-->" << pos.second->get_key() <<
" " <<
endl;
143 for (
int i = 0; i < n/2; i++)
147 cout <<
value <<
" ";
155 cout <<
endl <<
"verifying Splay_Rk after deletions ... "
158 cout <<
" done" <<
endl;
160 cout <<
"Inorden" <<
endl;
Core header for the Aleph-w library.
size_t size_t int32_t value
Set-like container backed by a dynamic array.
void reserve(const size_t l, const size_t r)
Allocate a range of entries.
std::pair< long, Node * > position(const Key &key)
Returns the inorder (sorted) position of key.
Node * insert(Node *p)
Inserts a node in a top down splay tree.
Node * remove(const Key &key)
Remove a key from a top-down splay tree.
Node * search(const Key &key)
Searches a key in a top down splay tree.
Node * select(const size_t &i)
Returns the node whose inorder position in the extended tree is i.
Node *& getRoot()
Get the top-down splay tree's root.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
bool check_rank_tree(Node *root) noexcept
Return true if root is a valid extended binary tree.
size_t internal_path_length(Node *p) noexcept
Compute the internal path length.
int inOrderRec(Node *root, void(*visitFct)(Node *, int, int))
Traverse recursively inorder a binary tree.
void destroyRec(Node *&root) noexcept
Free recursively all the memory occupied by the tree root
Main namespace for Aleph-w library functions.
void quicksort(T *a, const long l, const long r, const Compare &cmp=Compare())
Sort an array using iterative quicksort with optimizations.
void printNode(Splay_Tree_Rk< int >::Node *node, int, int)
Utility functions for binary tree operations.
Comprehensive sorting algorithms and search utilities for Aleph-w.
Top-down splay tree with rank support.