45 cout << node->get_key() <<
" ";
50 cout << node->getPriority() <<
" ";
59 try { n =
stoi(
argv[1]); }
catch (...) { n = 10; }
64 cerr <<
"n must be positive" <<
endl;
68 unsigned int t = std::time(0);
71 try { t =
stoul(
argv[2]); }
catch (...) { t = std::time(0); }
76 cout <<
"testTreap_Rk " << n <<
" " << t <<
endl;
83 cout <<
"Inserting " << n <<
" random values in tree ...\n";
85 for (i = 0; i < n; i++)
105 <<
"Preorden" <<
endl;
111 cout <<
"inorden prio" <<
endl;
115 for (i = 0; i < n; i++)
118 cout << node->get_key() <<
" ";
123 cout <<
"Lista de posiciones infijas" <<
endl;
125 for (i = 0; i < n; ++i)
127 std::pair<int,Treap_Rk<int>::Node*> pos = tree.
position(
keys[i]);
128 cout <<
keys[i] <<
"<-->" << pos.first <<
endl;
133 for (i = 0; i < n/2; i++)
136 node = tree.
remove(value);
139 cout << value <<
" ";
143 cout <<
endl <<
"verifying Treap_Rk after deletions ... "
147 cout <<
" done" <<
endl;
149 cout <<
"Preorden" <<
endl;
153 cout <<
"inorden prio" <<
endl;
160 cout <<
"Recorrido por iterador" <<
endl;
162 cout <<
KEY(it.get_curr()) <<
" ";
168 cout <<
"Eliminacion de rango [" <<
beg <<
" .. " << end <<
"]" <<
endl;
178 cout <<
"Arbol restante" <<
endl;
182 cout <<
"Arbol eliminado" <<
endl;
190 cout <<
endl <<
"testTreap_Rk " << n <<
" " << t <<
endl;
Core header for the Aleph-w library.
Node *& getRoot() noexcept
Return the tree's root.
Node * select(const size_t i) const
Return the i-th node in order sense.
size_t size() const noexcept
Return the number of nodes contained in the tree.
Node * search(const Key &key) const noexcept
Search a key in a treap.
Node * remove(Node *&root, const Key &key) noexcept
bool insert(Node *&root, Node *p) noexcept
int preOrderRec(Node *root, void(*visitFct)(Node *, int, int))
Traverse recursively in preorder a binary tree.
bool check_rank_tree(Node *root) noexcept
Return true if root is a valid extended binary tree.
std::pair< int, Node * > position(const Key &key) const noexcept
Compute the inorder position of a key.
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.
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.
Extended treap (a special type of randomized binary search tree) which manages selection and splittin...
void printNode(Treap_Rk< int >::Node *node, int, int)
void printPrio(Treap_Rk< int >::Node *node, int, int)
Utility functions for binary tree operations.
Lazy and scalable dynamic array implementation.
Treap with rank (order statistics).