7&8. Trees
7&8. Trees
Tushar B. Kute,
http://tusharkute.com
Choosing a Data Structure
• struct node
{
int data;
struct node *left;
struct node *right;
}
• The above structure can only be defined for the binary
trees because the binary tree can have utmost two children,
and generic trees can have more than two children.
• The structure of the node for generic trees would be
different as compared to the binary tree.
Tree: Application
A→B→D→E→C→F→G
Postorder Traversal
D→E→B→F→G→C→A
Inorder Traversal
D→B→E→A→F→C→G
Complexities of Tree Traversal
Web Resources
https://mitu.co.in
@mituskillologies http://tusharkute.com @mituskillologies