43 static ofstream
output(
"bin-tree-aux.Tree", ios::out);
46 output << p->get_key() <<
" ";
52 static ofstream
example(
"example-34-ar-aux.Tree", ios::out);
60 static ofstream
tex(
"example-34-aux.tex", ios::out);
63 tex <<
" $" << p->get_key() <<
"\\ $";
73 catch (...) { n = 1000; }
76 unsigned int t = std::time(0);
79 try { t =
static_cast<unsigned int>(
stoul(
argv[2])); }
80 catch (...) { t = std::time(0); }
85 cout <<
"writeBinTree " << n <<
" " << t <<
endl;
90 for (
int i = 0; i < 30; i++)
95 value = std::uniform_int_distribution<int>(0, 499)(
rng);
107 for (
int i = 0; i < n; i++)
112 value = std::uniform_int_distribution<int>(0, n * 10 - 1)(
rng);
113 node = tree.
search(value);
Exception handling system with formatted messages for Aleph-w.
#define ah_runtime_error()
Throws std::runtime_error unconditionally.
Core header for the Aleph-w library.
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.
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.
Binary search tree with nodes without virtual destructors,.
Utility functions for binary tree operations.
Generic unbalanced binary search tree.
static void print_key(BinTree< int >::Node *p, int, int)
static void print_tex(BinTree< int >::Node *p, int, int)
static void print_ex(BinTree< int >::Node *p, int, int)