146# include <gsl/gsl_rng.h>
184 cout <<
"(" << node->get_key() <<
"," << node->get_data() <<
")";
192 return x != 0
and not (x & (x - 1));
199template <
typename Key>
208template <
template <
typename,
class>
class TreeType,
214 cout <<
"Sampling at 2^" <<
k <<
" = " << n <<
" ..." <<
endl;
218 cout <<
" Computing height ..." <<
endl;
220 cout <<
" done = " << height <<
endl
222 <<
" Computing IPL ..." <<
endl;
228 using Chrono = std::chrono::high_resolution_clock;
238 while (tree.search(value) !=
nullptr)
248 (
void) tree.insert(p);
307 <<
" height = " << height <<
endl
317template <
template <
typename ,
class >
class TreeType>
323 static const size_t N = 64;
325 int height[
N],
ipl[
N];
328 for (
unsigned int i = 0; i < n; i++)
351 printf(
"#2^k n h ipc [min ins med sigma max] [min ins med sigma max]\n");
352 for (
int i = 0; i <
num_pow; ++i)
356 printf(
"%02d %08d %02d %08d %02.2f %02.2f %02.2f %02.2f %02.2f"
357 " %02.2f %02.2f %02.2f %02.2f %02.2f\n",
358 i, (
int)
pow(2, i), height[i],
ipl[i],
382template <
template <
typename,
class>
class Tree>
418 return bench.type == type;
441static char doc[] =
"timeAllTree -- Benchmark Aleph tree implementations";
442static char argDoc[] =
"-n num_nodes -m seed_for_random [tree options]\n";
471 "Specify the number of nodes to be generated", 0
475 "Specify the seed for randon number generator", 0
486 parsPtr->selected.push_back(type);
495 if (state->argv[state->next] ==
nullptr)
498 if (*end !=
'\0' && *end !=
'\n')
542 if (state->argv[state->next] ==
nullptr)
545 if (*end !=
'\0' && *end !=
'\n')
564 unsigned long n = pars.
n;
569 std::vector<const TreeBenchmark *>
benches;
584 AH_ERROR((
"No valid tree types selected"));
590 cout <<
"timeAllTree<" <<
bench->label <<
"> "
594 cout <<
"timeAllTree<" <<
bench->label <<
"> "
598 catch (exception & e)
600 cout <<
"**** Exception: " << e.what() <<
endl;
#define AH_ERROR(format, args...)
Print an error message (always enabled).
WeightedDigraph::Node Node
void empty() noexcept
empty the list
Node * insert(Node *p) noexcept
Insert a node in the tree.
Node *& getRoot() noexcept
Return the tree's root.
Node * search(const Key &key) const noexcept
Search a key.
iterator end() noexcept
Return an STL-compatible end iterator.
__gmp_expr< T, __gmp_unary_expr< __gmp_expr< T, U >, __gmp_log_function > > log(const __gmp_expr< T, U > &expr)
__gmp_expr< T, __gmp_unary_expr< __gmp_expr< T, U >, __gmp_sqrt_function > > sqrt(const __gmp_expr< T, U > &expr)
__gmp_expr< typename __gmp_resolve_expr< T, V >::value_type, __gmp_binary_expr< __gmp_expr< T, U >, __gmp_expr< V, W >, __gmp_pow_function > > pow(const __gmp_expr< T, U > &expr1, const __gmp_expr< V, W > &expr2)
size_t internal_path_length(Node *p) noexcept
Compute the internal path length.
void destroyRec(Node *&root) noexcept
Free recursively all the memory occupied by the tree root
size_t computeHeightRec(Node *root) noexcept
Compute recursively the height of root
@ Tree
Basic arc (in spanning tree).
DynList< T > maps(const C &c, Op op)
Classic map operation.
Itor::difference_type count(const Itor &beg, const Itor &end, const T &value)
Count elements equal to a value.
bool operator()(const Sample &t1, const Sample &t2) const
std::vector< TreeType > selected
Parameters(int _n, int _seed)
void(* runner)(unsigned long, gsl_rng *)
void test(unsigned long n, gsl_rng *r)
static void printNode(Node *node, int, int)
tuple< int, double > Sample
bool is_two_power(const unsigned int x)
static const TreeBenchmark * find_benchmark(TreeType type)
const char * argp_program_version
static error_t parser_opt(int key, char *, struct argp_state *state)
void run_tree(unsigned long n, gsl_rng *r)
tuple< Stat, Stat, int, int > sample_tree(TreeType< Key, Compare > &tree, gsl_rng *r, int n, int k)
tuple< double, double, double, double, double > Stat
const char * argp_program_bug_address
static const std::array< TreeBenchmark, 12 > kBenchmarks
static struct argp_option options[]
static struct argp argDefs
constexpr int Num_Samples
AVL tree with rank (order statistics).
AVL tree implementation (height-balanced BST).
Utility functions for binary tree operations.
Generic unbalanced binary search tree.
Dynamic key-value map based on balanced binary search trees.
Randomized binary search tree.
Red-Black tree with rank (order statistics).
Red-Black tree implementation (bottom-up balancing).
Comprehensive sorting algorithms and search utilities for Aleph-w.
Top-down splay tree with rank support.
Top-down splay tree implementation (without rank support).
Top-down Red-Black tree with rank support.
Top-down Red-Black tree implementation.
Treap with rank (order statistics).
Treap: randomized BST combining tree and heap properties.