46 cout << p->get_key() <<
" ";
49static int r[] = { 776, 846, 736, 515, 528, 677, 404, 629, 879, 762 };
51int main(
int argc,
char *argv[])
54 unsigned int t = std::time(0);
71 cerr <<
"Error: n must be a positive integer." << endl;
89 cout <<
"testSplayTree " << n <<
" " << t << endl;
95 cout <<
"Inserting " << n <<
" random values in treee ...\n";
97 unsigned int insCount = 0, delCount = 0;
99 for (i = 0; i < n; i++)
101 value = 1+(int) (n*10.0*rand()/(RAND_MAX+1.0));
109 cout <<
value <<
" ";
114 cout << endl <<
"Preorder " << endl << endl;
117 cout << endl << insCount <<
" Items inserted" << endl;
119 for (i = 0; i < n; i++)
121 value = 1+(int) (n*100.0*rand()/(RAND_MAX+1.0));
130 cout << delCount <<
" Items removed" << endl;
133 cout <<
"testSplayTree " << n <<
" " << t << endl;
Core header for the Aleph-w library.
size_t size_t int32_t value
Node *& getRoot() noexcept
Get the top-down splay tree's root.
Node * remove(const Key &key) noexcept
Remove a key from a top down splay tree.
Node * insert(Node *p) noexcept
Inserts a node in a top-down splay tree.
Node * search(const Key &key) noexcept
Searches a key in a top-down splay tree.
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.
static void print(Splay_Tree< int >::Node *p, int, int)
Utility functions for binary tree operations.
Top-down splay tree implementation (without rank support).