29# include <gsl/gsl_rng.h>
40 cout <<
KEY(p) <<
" " ;
46 cout <<
KEY(p) <<
" " ;
56 catch (...) { n = 1000; }
61 cerr <<
"Error: n must be a positive integer." <<
endl;
65 unsigned int seed = 0;
69 catch (...) {
seed = 0; }
75 cout <<
"test_Splay_Tree " << n <<
" " <<
seed <<
endl;
82 cout <<
"Testing for insertions" <<
endl;
84 for (
int i = 0; i < n; i++)
103 cout <<
endl <<
"Preorder " <<
endl;
108 cout <<
"Testing for random searches" <<
endl;
109 for (
int i = 0; i < n; ++i)
112 int value = values(idx);
113 cout << value <<
" ";
115 AH_ERROR(
"BUG detected ins searching");
117 cout <<
"Done" <<
endl;
119 cout <<
"Removing test" <<
endl;
121 for (
int i = 0; i < n/7; i++)
125 cout << value <<
" ";
127 assert(value == p->get_key());
139 DynList<int>({122, 363, 1247, 510, 701, 1565, 1157, 728, 1564, 492, 861, 422}).
144 cout <<
endl <<
"Preorder " <<
endl;
#define AH_ERROR(format, args...)
Print an error message (always enabled).
Set-like container backed by a dynamic array.
void remove(T &item)
Given a valid reference to an item in the array, it removes it and decrease the dimension.
size_t size() const noexcept
Return the current dimension of array.
T & append()
Allocate a new entry to the end of array.
Dynamic singly linked list with functional programming support.
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.
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
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.
Operation for_each(Itor beg, const Itor &end, Operation op)
Apply an operation to each element in a range.
void print_node(Splay_Tree< int >::Node *p, int, int)
void write_node(Splay_Tree< int >::Node *p, int, int)
Top-down splay tree implementation (without rank support).