46# include <gsl/gsl_rng.h>
60 cout << node->get_key() <<
" ";
81 cout <<
"(" << idx <<
":" << p->
get_key() <<
")";
94 unsigned int t = std::time(0);
102 cout <<
argv[0] <<
" " << n <<
" " << t <<
endl;
111 cerr <<
"Error: n must be <= 1000 to avoid infinite loops with current RNG range." <<
endl;
115 cout <<
"Inserting " << n <<
" random values in tree ...\n";
117 for (
int i = 0; i < n; i++)
126 while (node
not_eq nullptr);
132 cout <<
value <<
" ";
140 if (
ttree ==
nullptr)
142 cout <<
"Warning: Empty tree, no forest to process." <<
endl;
148 cout <<
endl <<
"Secuencia paréntesis: ";
150 auto rc =
ttree->get_right_sibling();
151 while (
rc !=
nullptr)
154 rc =
rc->get_right_sibling();
158 cout <<
"Secuencia en notación Deway: ";
160 rc =
ttree->get_right_sibling();
162 while (
rc !=
nullptr)
167 rc =
rc->get_right_sibling();
175 <<
"prefijo: " <<
endl;
179 cout <<
"sufijo: " <<
endl;
183 cout <<
"infijo: " <<
endl;
191 cout <<
"IPL = " <<
ipl <<
endl
192 <<
"EPL = " <<
ipl + 2*n <<
endl;
207 cout <<
"Removing " << n/4 <<
" keys" <<
endl;
209 std::vector<int>
keys;
211 keys.push_back(node->get_key());
213 std::shuffle(
keys.begin(),
keys.end(), std::mt19937(t));
215 for (
size_t i = 0; i < (size_t)(n/4) && i <
keys.size(); i++)
222 cout << node->get_key() <<
" ";
239 cout <<
argv[0] <<
" " << n <<
" " << t <<
endl;
Core header for the Aleph-w library.
size_t size_t int32_t value
Node *& getRoot() noexcept
Return the root of tree.
Node * insert(Node *p) noexcept
Insert a node in the tree.
Node * search(const Key &key) const noexcept
Search a key.
Node * remove(const Key &key) noexcept
Remove a key from the tree.
Forward declaration used by CRTP helpers before the full node definition.
void for_each_child(Operation &op) const
Visits each child of this and executes the operation on the child node.
T & get_key() noexcept
Returns a modifiable reference to the node contents.
Tree visualization and output generation.
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 postOrderRec(Node *root, void(*visitFct)(Node *, int, int))
Traverse recursively in postorder a binary tree.
int preOrderRec(Node *root, void(*visitFct)(Node *, int, int))
Traverse recursively in preorder a binary tree.
Node * copyRec(Node *root)
Copy recursively a tree.
size_t internal_path_length(Node *p) noexcept
Compute the internal path length.
void destroy_forest(Node *root)
Destroys (frees memory) the forest whose first tree is root.
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
void split_key(Node *&root, const Key &key, Node *&l, Node *&r, const Compare &cmp=Compare()) noexcept
Split a binary search tree according to a key.
Main namespace for Aleph-w library functions.
std::string code(Node *root)
Compute a string with the Lukasiewicz`s word of a tree.
std::string to_string(const time_t t, const std::string &format)
Format a time_t value into a string using format.
Binary search tree with nodes without virtual destructors,.
void operator()(gsl_rng *r) const
string operator()(Tree_Node< int > *p)
std::unique_ptr< gsl_rng, GslRngDeleter > GslRngHandle
void print_forest_par(Tree_Node< int > *p)
void print_forest_deway(Tree_Node< int > *p, const string &idx)
static void printNode(BinTree< int >::Node *node, int, int)
Generic unbalanced binary search tree.
General tree (n-ary tree) node.