38# include <gsl/gsl_rng.h>
46 cout <<
"(" << node->get_key() <<
"," << node->get_data() <<
")";
51 template <
typename ,
class >
55 unsigned long max = 100*n;
60 for (i = 0; i < n; i++)
66 cout <<
"Reading test ... " <<
endl;
70 for (i = 0; i < n; i++)
75 content = tree.
find(value);
86 cout <<
"Writing test ... " <<
endl;
88 for (i = 0; i < n; i++)
91 auto val = tree.
insert(value, i);
92 cout <<
"(" << val <<
"," << i <<
")";
99 cout <<
"The height is " << tree.
height() <<
endl;
104 for (i = 0; i < n; i++)
136static char doc[] =
"testAllTree -- A tester for all binary trees";
137static char argDoc[] =
"-n num_nodes -m seed_for_random -<tree type>\n"
148 "Specify the number of nodes to be generated", 0 },
150 "Specify the seed for randon number generator", 0},
166 if (state->argv[state->next] ==
NULL)
169 if (*end !=
'\0' && *end !=
'\n')
198 if (state->argv[state->next] ==
NULL)
201 if (*end !=
'\0' && *end !=
'\n')
217 cout <<
"testAllTree -- stress-test for Aleph-w binary search trees\n"
219 <<
"Inserts, searches, and removes random keys in a DynMapTree backed by\n"
220 <<
"the chosen tree type, then reports path length, height, and counts.\n"
223 <<
" " <<
argv[0] <<
" -<tree> [-n num_nodes] [-m seed]\n"
225 <<
"Tree type (required; last wins if repeated):\n"
226 <<
" -b, --bin Pure (unbalanced) binary tree\n"
227 <<
" -a, --avl AVL tree\n"
228 <<
" -s, --splay Splay tree\n"
229 <<
" -r, --redblack Red-black tree\n"
230 <<
" -p, --treap Treap (randomized BST with priorities)\n"
231 <<
" -d, --rand Randomized tree\n"
234 <<
" -n num_nodes Number of keys to insert (default: 1000)\n"
235 <<
" -m seed Seed for the random number generator (default: current time)\n"
238 <<
" " <<
argv[0] <<
" -a -n 5000 # AVL tree with 5000 nodes\n"
239 <<
" " <<
argv[0] <<
" -p -n 10000 -m 42 # Treap, 10000 nodes, seed 42\n";
253 unsigned long n = pars.
n;
258 cout <<
"testAllTree<" << pars.
str <<
"> " << n <<
" " << pars.
seed
287 cout <<
"testAllTree<" << pars.
str <<
"> " << n <<
" " << pars.
seed
290 catch (exception & e)
292 cout <<
"**** Exception: " << e.what() <<
endl;
#define AH_ERROR(format, args...)
Print an error message (always enabled).
Core header for the Aleph-w library.
WeightedDigraph::Node Node
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)
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.
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.