65 <<
"Secuencia aleatorios: ";
76 cout << node->get_key() <<
" ";
81 cout << node->get_key() <<
" ";
86 cout << node->getPriority() <<
" ";
91 cout <<
"(" << node->get_key() <<
"," << node->getPriority() <<
") ";
97 unsigned int t = std::time(0);
103 n = std::stoi(
argv[1]);
106 t = std::stoi(
argv[2]);
115 cout <<
"n must be positive" <<
endl;
121 cout <<
"testTreapRec " << n <<
" " << t <<
endl;
127 cout <<
"Inserting " << n <<
" random values in treee ...\n";
129 for (i = 0; i < n; i++)
134 node = tree.
search(value);
140 cout <<
"(" << value <<
"," <<
PRIO(node) <<
") ";
144 <<
"level order" <<
endl;
148 cout << p->get_key() <<
" ";
155 <<
"Preorden" <<
endl;
161 cout <<
"inorden prio" <<
endl;
171 <<
"Preorden prio" <<
endl;
177 cout <<
"inorden prio" <<
endl;
185 for (i = 0; i < n/2; i++)
190 node = tree.
remove(value);
192 while (node ==
NULL);
194 cout << value <<
" ";
198 cout <<
endl <<
"verifying Treap after deletions ... "
201 cout <<
" done" <<
endl;
203 cout <<
"Preorden" <<
endl;
207 cout <<
"inorden prio" <<
endl;
216 cout <<
endl <<
"testTreapRec " << n <<
" " << t <<
endl;
Core header for the Aleph-w library.
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
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.
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
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.