46 cout <<
"(" << p->
get_key() <<
"," << p->getCount() <<
")" ;
52 cout << p->get_key() <<
" ";
74 cerr <<
"Error: n must be greater than 1 for meaningful tree operations." <<
endl;
78 unsigned int t = std::time(0);
94 cout <<
argv[0] <<
" " << n <<
" " << t <<
endl;
99 for (
int i = 0; i < n - 1; i++)
104 cout << value <<
" ";
127 cout << p->get_key() <<
" ";
150 <<
"Pos of " << q->get_key() - 1 <<
" is " << pos <<
endl
151 <<
"Next key is " << q->get_key() <<
endl;
156 <<
"Pos of " << p->get_key() <<
" is " << pos <<
endl
157 <<
"key in node is " << q->get_key() <<
endl;
161 <<
"Pos of " << p->get_key() - 1 <<
" is " << pos <<
endl
162 <<
"key in node is " << q->get_key() <<
endl;
166 <<
"Pos of " << p->get_key() + 1 <<
" is " << pos <<
endl
167 <<
"key in node is " << q->get_key() <<
endl;
172 <<
"Pos of " << p->get_key() + 1 <<
" is " << pos <<
endl
173 <<
"Next key is " << p->get_key() <<
endl <<
endl;
180 cout <<
"Eliminando e insertando por clave " <<
num_nodes <<
endl;
189 cout <<
"listo" <<
endl;
191 cout <<
"Eliminando e insertando por posicion " <<
num_nodes <<
endl;
200 cout <<
"listo" <<
endl;
202 cout <<
"Eliminando e insertando por clave " <<
num_nodes <<
endl;
216 cout <<
"listo" <<
endl;
221 cout <<
endl <<
endl <<
"Particionando recursivamente ... " <<
endl <<
endl;
224 cout <<
" ... listo" <<
endl;
Core header for the Aleph-w library.
WeightedDigraph::Node Node
Node for extended binary search tree.
static BinNodeXt *const NullPtr
__gmp_expr< T, __gmp_binary_expr< __gmp_expr< T, U >, unsigned long int, __gmp_root_function > > root(const __gmp_expr< T, U > &expr, unsigned long int l)
int preOrderRec(Node *root, void(*visitFct)(Node *, int, int))
Traverse recursively in preorder a binary tree.
long inorder_position(Node *r, const typename Node::key_type &key, Node *&p, Compare &cmp) noexcept
Compute the inorder position of a key.
Node * insert_by_key_xt(Node *&r, Node *p, Compare &cmp) noexcept
Insert a node in an extended binary search tree.
bool check_rank_tree(Node *root) noexcept
Return true if root is a valid extended binary tree.
void split_pos_rec(Node *&r, const size_t i, Node *&ts, Node *&tg)
Split a extended binary tree according to a position.
bool check_bst(Node *p, const Compare &cmp=Compare())
Return true if p is a binary search tree.
Node * remove_by_pos_xt(Node *&root, size_t pos)
Remove from a extended binary tree the node whose inorder position is pos.
Node * remove_by_key_xt(Node *&root, const typename Node::key_type &key, Compare &cmp) noexcept
Remove a key of extended binary tree.
int inOrderRec(Node *root, void(*visitFct)(Node *, int, int))
Traverse recursively inorder a binary tree.
Node * select(Node *r, const size_t pos)
Iterative selection of a node according to inorder position.
void destroyRec(Node *&root) noexcept
Free recursively all the memory occupied by the tree root
Node * searchInBinTree(Node *root, const typename Node::key_type &key, const Compare &cmp=Compare()) noexcept
Search a key in a binary search tree.
void insert_by_pos_xt(Node *&r, Node *p, size_t pos)
Insert a node in a specific inorder position in a binary tree.
Node * select_rec(Node *r, const size_t i)
Recursively select the i-th node inorder sense.
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.
long find_position(Node *r, const typename Node::key_type &key, Node *&p, Compare &cmp) noexcept
Find the inorder position of a key in an extended binary search tree.
void print_node(Node *p, int, int)
void print_key(Node *p, int, int)
Utility functions for binary tree operations.
Extended binary node with subtree count.
Generic unbalanced binary search tree.
Lazy and scalable dynamic array implementation.