41 cout << node->
get_data() <<
" level = " << level <<
" index = "
48 string::size_type len = str.size();
50 for (string::size_type i = 0; i < len; i++)
51 if (
not std::isdigit(
static_cast<unsigned char>(str[i])))
76 <<
"character is not a digit";
85 for (
int i = 0; i < a.
size(); i++)
98 cout <<
"Enter the root value: ";
101 cout <<
"Error: Invalid input for root value." <<
endl;
107 cout <<
"Entering tree nodes (deway then number) (any letter to finish)"
114 cout <<
" Parent Deway number = ";
130 cout <<
" Inserting rightmost child in " <<
deway_string
132 <<
" New node key = ";
145 catch (invalid_argument & e)
147 cout << e.what() <<
endl
148 <<
"Finishing " <<
endl;
153 cout <<
"Out of memory";
157 cout <<
" preorder" <<
endl;
160 cout <<
" postorder" <<
endl;
Exception handling system with formatted messages for Aleph-w.
#define ah_invalid_argument_if(C)
Throws std::invalid_argument if condition holds.
size_t size() const noexcept
Return the current dimension of array.
T & get_data() noexcept
Returns a modifiable reference to the node contents.
void insert_rightmost_child(Tree_Node *p) noexcept
Inserts p as the rightmost child of this.
void deway(Tree_Node< int > *p, int prefix[], const int &len, const size_t &dim)
Recursively compute and print Deway numbering for a tree node.
__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)
void destroy_tree(Node *root)
Destroys (frees memory) the tree whose root is root.
void tree_postorder_traversal(Node *root, void(*visitFct)(Node *, int, int))
Postorder traversal of a tree.
bool are_tree_equal(Node *t1, Node *t2, Eq &eq)
Returns true if t1 is equal to t2.
void tree_preorder_traversal(Node *root, void(*visitFct)(Node *, int, int))
Preorder traversal of a tree.
Node * deway_search(Node *root, int path[], const size_t &size)
Returns a node of a forest given its Dewey number.
size_t size(Node *root) noexcept
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.
static void clone_tree(Node *src, Node *tgt)
void print_node(Tree_Node< int > *node, int level, int index)
int * string_to_deway(const string &str, size_t &size)
bool is_string_an_int(const string &str)
Lazy and scalable dynamic array implementation.
General tree (n-ary tree) node.