42ofstream
file(
"avl-tree-aux.Tree", ios::out);
47 file << p->get_key() <<
" ";
56 try { n =
stoi(
argv[1]); }
catch (...) { n = 1000; }
61 cerr <<
"n must be positive" <<
endl;
65 unsigned int t = std::time(0);
68 try { t =
stoul(
argv[2]); }
catch (...) { t = std::time(0); }
73 cout <<
"writeAvl " << n <<
" " << t <<
endl;
79 cout <<
"Inserting " << n <<
" random values in treee ...\n";
81 for (i = 0; i < n; i++)
92 cout <<
endl <<
"verifying avl tree after insertions ... "
95 cout <<
" done" <<
endl;
Core header for the Aleph-w library.
bool is_avl(Node *p)
Validate that a tree satisfies AVL properties.
Node * search(const Key &key) const noexcept
Search a node containing key; if found, then a pointer to the node containing it is returned; otherwi...
constexpr Node *& getRoot() noexcept
Return a modifiable reference to tree's root.
Node * insert(Node *p) noexcept
Insert the node pointed by p in the tree.
int preOrderRec(Node *root, void(*visitFct)(Node *, int, int))
Traverse recursively in preorder 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.
AVL binary search tree with nodes without virtual destructor.
AVL tree implementation (height-balanced BST).
Utility functions for binary tree operations.
static void print_key(Avl_Tree< int >::Node *p, int, int)