43# include <gsl/gsl_rng.h>
51 cout <<
"(" << node->get_key() <<
"," << node->get_data() <<
")";
56 template <
typename ,
class >
60 unsigned long max = 100*n;
65 for (i = 0; i < n; i++)
71 cout <<
"Reading test ... " <<
endl;
75 for (i = 0; i < n; i++)
91 cout <<
"Writing test ... " <<
endl;
93 for (i = 0; i < n; i++)
97 cout <<
"(" << val <<
"," << i <<
")";
104 cout <<
"The height is " << tree.
height() <<
endl;
109 for (i = 0; i < n; i++)
141static char doc[] =
"testAllTree -- A tester for all binary trees";
142static char argDoc[] =
"-n num_nodes -m seed_for_random -<tree type>\n"
153 "Specify the number of nodes to be generated", 0 },
155 "Specify the seed for randon number generator", 0},
171 if (state->argv[state->next] ==
NULL)
174 if (*end !=
'\0' && *end !=
'\n')
203 if (state->argv[state->next] ==
NULL)
206 if (*end !=
'\0' && *end !=
'\n')
222 cout <<
"testAllTree -- stress-test for Aleph-w binary search trees\n"
224 <<
"Inserts, searches, and removes random keys in a DynMapTree backed by\n"
225 <<
"the chosen tree type, then reports path length, height, and counts.\n"
228 <<
" " <<
argv[0] <<
" -<tree> [-n num_nodes] [-m seed]\n"
230 <<
"Tree type (required; last wins if repeated):\n"
231 <<
" -b, --bin Pure (unbalanced) binary tree\n"
232 <<
" -a, --avl AVL tree\n"
233 <<
" -s, --splay Splay tree\n"
234 <<
" -r, --redblack Red-black tree\n"
235 <<
" -p, --treap Treap (randomized BST with priorities)\n"
236 <<
" -d, --rand Randomized tree\n"
239 <<
" -n num_nodes Number of keys to insert (default: 1000)\n"
240 <<
" -m seed Seed for the random number generator (default: current time)\n"
243 <<
" " <<
argv[0] <<
" -a -n 5000 # AVL tree with 5000 nodes\n"
244 <<
" " <<
argv[0] <<
" -p -n 10000 -m 42 # Treap, 10000 nodes, seed 42\n";
258 unsigned long n = pars.
n;
263 cout <<
"testAllTree<" << pars.
str <<
"> " << n <<
" " << pars.
seed
292 cout <<
"testAllTree<" << pars.
str <<
"> " << n <<
" " << pars.
seed
295 catch (exception & e)
297 cout <<
"**** Exception: " << e.what() <<
endl;
#define AH_ERROR(...)
Print an error message (always enabled).
Core header for the Aleph-w library.
WeightedDigraph::Node Node
size_t size_t int32_t value
Generic key-value map implemented on top of a binary search tree.
Data remove(const Key &key)
Deletes the pair key,data
Pair * insert(const Key &key, const Data &data)
Insert a key-value pair.
Data & find(const Key &key)
Find the value associated with key.
size_t height() const
Calculates and returns the height of the binary search tree.
const size_t & size() const
Returns the cardinality of the set.
size_t internal_path_length() const
Calculates and returns the length of the internal path of the tree search binary.
__gmp_expr< typename __gmp_resolve_expr< T, V >::value_type, __gmp_binary_expr< __gmp_expr< T, U >, __gmp_expr< V, W >, __gmp_max_function > > max(const __gmp_expr< T, U > &expr1, const __gmp_expr< V, W > &expr2)
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Parameters(int _n, int _seed)
static void printNode(Node *node, int, int)
const char * argp_program_version
static error_t parser_opt(int key, char *, struct argp_state *state)
const char * argp_program_bug_address
static struct argp_option options[]
static struct argp argDefs
AVL tree implementation (height-balanced BST).
Generic unbalanced binary search tree.
Dynamic key-value map based on balanced binary search trees.
Randomized binary search tree.
Red-Black tree implementation (bottom-up balancing).
Top-down splay tree implementation (without rank support).
Treap: randomized BST combining tree and heap properties.