53 *
k++ = node->get_key();
92 try { n = std::stoi(
argv[1]); }
93 catch (...) { n = 10; }
98 cerr <<
"n must be greater than 0" <<
endl;
106 catch (...) {
prob = 0.5; }
109 unsigned int t =
static_cast<unsigned int>(
time(
nullptr));
112 try { t =
static_cast<unsigned int>(std::stoul(
argv[3])); }
113 catch (...) { t =
static_cast<unsigned int>(
time(
nullptr)); }
118 cout <<
argv[0] <<
" " << n <<
" " <<
prob <<
" " << t <<
" " <<
endl;
120 std::vector<int>
keys(
static_cast<size_t>(n));
126 for (
int i = 0; i < n; i++)
130 value =
static_cast<int>(10.0 * n *
rand() / (
RAND_MAX + 1.0));
144 std::vector<double> p(
static_cast<size_t>(n));
145 for (
int i = 0; i < n; i++)
148 printf(
"%.5f ", p[
static_cast<size_t>(i)]);
Node for binary search tree.
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.
__gmp_expr< typename __gmp_resolve_expr< T, V >::value_type, __gmp_binary_expr< __gmp_expr< T, U >, __gmp_expr< V, W >, __gmp_min_function > > min(const __gmp_expr< T, U > &expr1, const __gmp_expr< V, W > &expr2)
__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)
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
Main namespace for Aleph-w library functions.
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.
Optimal Binary Search Tree construction using dynamic programming.
Binary search tree with nodes without virtual destructors,.
void print(BinNode< int > *node, int, int)
void assign(BinTree< int >::Node *node, int, int)
double bin_coef(int n, int k)
Utility functions for binary tree operations.
Generic unbalanced binary search tree.