43 cout <<
"(" << p->get_key() <<
"," << (
int) (p->getDiff()) <<
") ";
48 cout << p->get_key() <<
" ";
54 unsigned int t = std::time(0);
71 cerr <<
"Error: n must be a positive integer." <<
endl;
89 cout <<
"testAvl " << n <<
" " << t <<
endl;
96 cout <<
"Inserting " << n <<
" random values in tree ...\n";
98 for (i = 0; i < n; i++)
103 node = tree.
search(value);
105 while (node
not_eq nullptr);
107 cout << value <<
" ";
112 cout <<
endl <<
"verifying avl tree after insertions ... "
115 cout <<
" done" <<
endl;
117 cout <<
"start-prefix ";
127 for (i = 0; i < n/2; i++)
130 node = tree.
remove(value);
133 cout << value <<
" ";
142 cout <<
endl <<
"verifying avl tree after deletions ... " ;
144 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.
Node * remove(const Key &key) noexcept
Remove from an AVL tree the node containing key 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.
AVL binary search tree with nodes without virtual destructor.
static void print(Avl_Tree< int >::Node *p, int, int)
static void print_pair(Avl_Tree< int >::Node *p, int, int)
AVL tree implementation (height-balanced BST).
Utility functions for binary tree operations.