Data Structures & Algorithms in C++
Goodrich, Tamassia, Mount and Goldwasser
|
Code from the chapter "Trees". More...
Data Structures | |
class | LinkedBinaryTree |
Functions | |
template<typename Position , typename Container > | |
void | inorder (Position p, Container &visited) |
template<typename Position > | |
void | print_preorder_indent (Position p, int d=0) |
Prints preorder representation of subtree rooted at p having depth d. | |
template<typename Position > | |
void | print_preorder_labeled (Position p, std::vector< int > &path) |
Prints labeled representation of subtree rooted at p having depth d. | |
template<typename Position > | |
void | parenthesize (Position p) |
Prints parenthesized representation of subtree rooted at p. | |
template<typename Position > | |
int | disk_space (Position p) |
Returns total disk space of elements stored in subtree rooted at p. | |
template<typename Position > | |
int | layout (Position p, int d, int x) |
template<typename Position > | |
int | depth (Position p) |
returns the number of proper ancestors of p | |
template<typename Tree > | |
int | height_bad (const Tree &t) |
template<typename Position > | |
int | height (Position p) |
template<typename Position , typename Container > | |
void | preorder (Position p, Container &visited) |
template<typename Position , typename Container > | |
void | postorder (Position p, Container &visited) |
template<typename Position > | |
std::queue< Position > | breadthfirst (Position p) |
Code from the chapter "Trees".
std::queue< Position > dsac::tree::breadthfirst | ( | Position | p | ) |
int dsac::tree::depth | ( | Position | p | ) |
returns the number of proper ancestors of p
int dsac::tree::disk_space | ( | Position | p | ) |
Returns total disk space of elements stored in subtree rooted at p.
int dsac::tree::height | ( | Position | p | ) |
int dsac::tree::height_bad | ( | const Tree & | t | ) |
void dsac::tree::inorder | ( | Position | p, |
Container & | visited | ||
) |
Returns total disk space of elements stored in subtree rooted at p d represents the known depth of p and x represents the next x-coordinate to be assigned returns the greatest x-coordinate that was assigned
void dsac::tree::parenthesize | ( | Position | p | ) |
Prints parenthesized representation of subtree rooted at p.
void dsac::tree::postorder | ( | Position | p, |
Container & | visited | ||
) |
void dsac::tree::preorder | ( | Position | p, |
Container & | visited | ||
) |
void dsac::tree::print_preorder_indent | ( | Position | p, |
int | d = 0 |
||
) |
Prints preorder representation of subtree rooted at p having depth d.
void dsac::tree::print_preorder_labeled | ( | Position | p, |
std::vector< int > & | path | ||
) |
Prints labeled representation of subtree rooted at p having depth d.