47ofstream
file(
"avl-tree-aux.Tree", ios::out);
52 file << p->get_key() <<
" ";
56int main(
int argc,
char *argv[])
61 try { n = stoi(argv[1]); }
catch (...) { n = 1000; }
66 cerr <<
"n must be positive" << endl;
70 unsigned int t = std::time(0);
73 try { t = stoul(argv[2]); }
catch (...) { t = std::time(0); }
78 cout <<
"writeAvl " << n <<
" " << t << endl;
84 cout <<
"Inserting " << n <<
" random values in treee ...\n";
86 for (i = 0; i < n; i++)
91 value = (int) (n*10.0*rand()/(RAND_MAX+1.0));
93 }
while (node not_eq NULL);
97 cout << endl <<
"verifying avl tree after insertions ... "
100 cout <<
" done" << endl;
Core header for the Aleph-w library.
bool is_avl(Node *p)
Validate that a tree satisfies AVL properties.
size_t size_t int32_t value
Node * insert(Node *p) noexcept(nothrow_compare_v< Compare, Key >)
Insert the node pointed by p in the tree.
constexpr Node *& getRoot() noexcept
Return a modifiable reference to tree's root.
Node * search(const Key &key) const noexcept(nothrow_compare_v< Compare, Key >)
Search a node containing key.
int preOrderRec(Node *root, void(*visitFct)(Node *, int, int))
Traverse recursively in preorder a binary tree.
void destroyRec(Node *&root) noexcept
Free all the memory occupied by the tree root
Main namespace for Aleph-w library functions.
AVL binary search tree with nodes without a 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)