68 std::vector<BinNode<int> *> allocated;
73 allocated.push_back(p);
96 const int mid = lo + (hi - lo) / 2;
105 std::cout <<
"[1] in-order / pre-order / post-order, driven lazily\n";
108 std::cout <<
"in-order: ";
110 std::cout <<
KEY(n) <<
" ";
113 std::cout <<
"pre-order: ";
115 std::cout <<
KEY(n) <<
" ";
118 std::cout <<
"post-order: ";
120 std::cout <<
KEY(n) <<
" ";
126 std::cout <<
"[2] Early stop: callback contract vs plain break\n";
129 constexpr int target = 5;
138 if (
KEY(n) == target)
142 std::cout <<
"Eager for_each_in_order searching for " << target <<
":\n";
153 if (
KEY(n) == target)
160 std::cout <<
"Eager infix_traverse searching for " << target <<
":\n";
170 if (
KEY(n) == target)
176 std::cout <<
"Lazy lazy_in_order searching for " << target <<
":\n";
178 <<
", nodes visited=" <<
lazy_visits <<
" (stopped as soon as found)\n\n";
180 std::cout <<
"In-order visits 1,2,3,4,5 before reaching the target 5. Both\n"
181 "infix_traverse and lazy_in_order avoid the remaining nodes;\n"
182 "the lazy version reads as ordinary iteration-with-break and\n"
183 "can be piped through other Generator stages.\n\n";
189 std::cout <<
"\n=== Lazy binary tree traversal ===\n\n";
197 std::cout <<
"Done.\n";
Node for binary search tree.
Conjunto de nodos a reusarse.
__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)
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
void for_each_in_order(Node *root, Op &&op)
Execute an operation in order sense for each node of tree.
Aleph::Generator< Node * > lazy_in_order(Node *root)
Lazily traverse a binary tree in-order (left, node, right).
Aleph::Generator< Node * > lazy_post_order(Node *root)
Lazily traverse a binary tree post-order (left, right, node).
Aleph::Generator< Node * > lazy_pre_order(Node *root)
Lazily traverse a binary tree pre-order (node, left, right).
bool infix_traverse(Node *root, Op op)
Traverse a tree in inorder via its iterator and performs a conditioned operation on each item.
Main namespace for Aleph-w library functions.
void print_rule()
Prints a horizontal rule for example output separation.
Lazy (coroutine-based) traversals of binary trees.
Utility functions for binary tree operations.
Basic binary tree node definitions.