






































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An in-depth exploration of tree concepts, including definitions, terminology, and tree adt methods. It also covers tree implementation using a struct in c and tree traversal methods such as preorder and postorder. The document also includes examples and explanations of binary trees.
Typology: Slides
1 / 46
This page cannot be seen from the preview
Don't miss anything!







































Crown
Church of
England Cabinet^
House of Commons
House of Lords
Supreme Court
Ministers County Council
Metropolitan police County Borough Council
Rural District Council Docsity.com
K L
E F
B
G
C
M
H I J
D
A
Level
1
2
3
4
node (13) degree of a node leaf (terminal) nonterminal parent children sibling degree of a tree (3) ancestor level of a node height of a tree (4)
Property Value Number of nodes Height Root Node Leaves Interior nodes Number of levels Ancestors of H Descendants of B Siblings of E Right subtree
The root comes first, followed by a list of sub-trees
data link 1 link 2 ... link n
How many link fields are needed in such a representation?
data left child right sibling
public void preorder(ptnode t) {
ptnode ptr; display(t->key); for(ptr = t->lchild; NULL != ptr; ptr = ptr->sibling) { preorder(ptr); } }
public void postorder(ptnode t) {
ptnode ptr; for(ptr = t->lchild; NULL != ptr; ptr = ptr->sibling) { postorder(ptr); } display(t->key); }
Boolean isEmpty( bt )::= if ( bt ==empty binary tree) return TRUE else return FALSE