54int main(
int argc,
char *argv[])
59 try { n = stoi(argv[1]); }
catch (...) { n = 1000; }
62 unsigned int t = std::time(0);
65 try { t = stoul(argv[2]); }
catch (...) { t = std::time(0); }
70 cout << argv[0] <<
" " << n <<
" " << t << endl;
80 cerr <<
"Error: n must be greater than 2 for meaningful tree splitting." << endl;
84 for (
int i = 0; i < n; i++)
86 value = (int) (10.0*n*rand()/(RAND_MAX+1.0));
88 while (tree.
insert(p) == NULL)
89 KEY(p) = (int) (10.0*n*rand()/(RAND_MAX+1.0));
95 cout << ins_count <<
" keys inserted" << endl;
102 value = (int) (10.0*n*rand()/(RAND_MAX+1.0));
105 cout <<
"Partition key: " <<
value << endl << endl;
107 cout <<
"Left Tree" << endl;
111 cout <<
"Right Tree" << endl;
Core header for the Aleph-w library.
size_t size_t int32_t value
Node for binary search tree.
Node * insert(Node *p) noexcept(nothrow_compare_copy_v< Compare, Key >)
Insert a node in the tree.
Node *& getRoot() noexcept
Return the root of tree.
bool split_key_rec(Node *&root, const typename Node::key_type &key, Node *&ts, Node *&tg, const Compare &cmp=Compare()) noexcept(nothrow_compare_v< Compare, typename Node::key_type >)
Split recursively according to a key.
bool check_bst(Node *p, const Compare &cmp=Compare())
Return true if p is a binary search tree.
void preOrderThreaded(Node *node, void(*visitFct)(Node *))
Traverse preorder a binary tree without recursion and without stack.
void destroyRec(Node *&root) noexcept
Free all the memory occupied by the tree root
Main namespace for Aleph-w library functions.
Binary search tree with nodes without virtual destructors,.
static void printNode(BinNode< int > *node)
Utility functions for binary tree operations.
Generic unbalanced binary search tree.