notebook.community
Edit and run
Tree data structures are recursive
Tree is a nonlinear data structure
<html> <head> </head> <body> <h1> This is a <u> Heading </u> </h1> <p> This is a paragraph with some <u> underlined </u> text. </p> </body> </html>
<style type="text/css"> h1 { color:blue; } u { color:red; } </style>
class Tree { public: };
template <typename Type> int Simple_tree<Type>::size() const { int s = 1; for ( Single_node<Simple_tree *> *ptr = children.head(); ptr != nullptr; ptr -> next(); ) { h = std::max(h, 1+ptr->retrieve()->height()); } }
We can use stacks for depth-first traversal.
template <typename Type> void Simple_tree<Type>::depth_first_traversal() const { std::cout << element << " "; for ( ) { ptr-> } };
template void Simple_tree<Type>::print(int depth) const { };
In [ ]: