37# include <gsl/gsl_rng.h>
40# include <string_view>
72 tex_file <<
"$(" << node->get_key() <<
"," <<
pri.get_si();
87 output << node->get_key() <<
" ";
106 unsigned int t = std::time(0);
111 const std::string_view
arg =
argv[1];
112 auto [ptr,
ec] = std::from_chars(
arg.data(),
arg.data() +
arg.size(), n);
114 <<
"Invalid or out-of-range value for n";
119 cerr <<
"n must be positive" <<
endl;
125 const std::string_view
arg =
argv[2];
126 auto [ptr,
ec] = std::from_chars(
arg.data(),
arg.data() +
arg.size(), t);
128 <<
"Invalid or out-of-range value for t";
133 output.open(
"treap-aux.Tree", ios::out | ios::trunc);
135 <<
"Could not open treap-aux.Tree";
136 fig_file.open(
"bal-04-aux.Tree", ios::out | ios::trunc);
138 <<
"Could not open bal-04-aux.Tree";
139 tex_file.open(
"treap-aux.tex", ios::out | ios::trunc);
141 <<
"Could not open treap-aux.tex";
143 cout <<
"writeTreap " << n <<
" " << t <<
endl;
150 cout <<
"Inserting " << n <<
" random values in tree ...\n";
152 for (i = 0; i < n; i++)
187 for (i = 0; i < n; i++)
Exception handling system with formatted messages for Aleph-w.
#define ah_runtime_error_if(C)
Throws std::runtime_error if condition holds.
#define ah_invalid_argument_if(C)
Throws std::invalid_argument if condition holds.
Core header for the Aleph-w library.
size_t size_t int32_t value
void set_seed(const unsigned long seed) noexcept
Set the random number generator seed.
Node * search(const Key &key) const noexcept
Search a key in a treap.
Node *& getRoot() noexcept
Return the tree's root.
gsl_rng * gsl_rng_object() noexcept
Get a pointer to gsl random number generator.
Node * insert(Node *root, Node *p) noexcept
__gmp_expr< mpz_t, mpz_t > mpz_class
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.
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
Node * find_max(Node *root) noexcept
Return the maximum key contained in a binary search tree.
Main namespace for Aleph-w library functions.
bool is_treap(Node *root) noexcept
Validate that a tree satisfies treap (heap) property.
gsl_rng * rand_gen
Internal RNG handle used by the helper functors in this header.
Treap (a special type of randomized binary search tree) using nodes without virtual destructor.
Utility functions for binary tree operations.
Treap: randomized BST combining tree and heap properties.
void print_key(Treap< int >::Node *node, int, int)
Treap< int >::Node * last_node
void print_treap(Treap< int >::Node *node, int, int)
void print_prio(Treap< int >::Node *node, int, int)
void print_pair(Treap< int >::Node *node, int, int)