70 <<
"Secuencia aleatorios: ";
81 cout << node->get_key() <<
" ";
86 cout << node->get_key() <<
" ";
91 cout << node->getPriority() <<
" ";
96 cout <<
"(" << node->get_key() <<
"," << node->getPriority() <<
") ";
102 unsigned int t = std::time(0);
108 n = std::stoi(
argv[1]);
111 t = std::stoi(
argv[2]);
120 cout <<
"n must be positive" <<
endl;
126 cout <<
"testTreapRec " << n <<
" " << t <<
endl;
132 cout <<
"Inserting " << n <<
" random values in treee ...\n";
134 for (i = 0; i < n; i++)
145 cout <<
"(" <<
value <<
"," <<
PRIO(node) <<
") ";
149 <<
"level order" <<
endl;
153 cout << p->get_key() <<
" ";
160 <<
"Preorden" <<
endl;
166 cout <<
"inorden prio" <<
endl;
176 <<
"Preorden prio" <<
endl;
182 cout <<
"inorden prio" <<
endl;
190 for (i = 0; i < n/2; i++)
197 while (node ==
NULL);
199 cout <<
value <<
" ";
203 cout <<
endl <<
"verifying Treap after deletions ... "
206 cout <<
" done" <<
endl;
208 cout <<
"Preorden" <<
endl;
212 cout <<
"inorden prio" <<
endl;
221 cout <<
endl <<
"testTreapRec " << n <<
" " << t <<
endl;
Core header for the Aleph-w library.
size_t size_t int32_t value
void cut(const size_t new_dim=0)
Cut the array to a new dimension; that is, it reduces the dimension of array and frees the remaining ...
Node * remove(const Key &key) noexcept
Remove a key from the tree.
Node * search(const Key &key) const noexcept
Search a key in a treap.
Node *& getRoot() noexcept
Return the tree's root.
Node * insert(Node *root, Node *p) noexcept
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
int preOrderRec(Node *root, void(*visitFct)(Node *, int, int))
Traverse recursively in preorder a binary tree.
bool level_traverse(Node *root, Operation &operation)
Level traverse a tree and execute an operation.
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
unsigned long & PRIO(Node *p) noexcept
Access the priority of a treap node.
Main namespace for Aleph-w library functions.
bool is_treap(Node *root) noexcept
Validate that a tree satisfies treap (heap) property.
long sequential_search(T *a, const T &x, const long l, const long r, Equal eq=Equal())
Linear search for an element in an array.
Treap (a special type of randomized binary search tree) using nodes without virtual destructor.
void printPair(Treap< int >::Node *node, int, int)
void printPrio(Treap< int >::Node *node, int, int)
void print_aleatorio_and_reset_dynarray()
DynArray< unsigned long > rand_sequence
void printNode(Treap< int >::Node *node, int, int)
Utility functions for binary tree operations.
Lazy and scalable dynamic array implementation.
Comprehensive sorting algorithms and search utilities for Aleph-w.
Treap: randomized BST combining tree and heap properties.