Lesson 7 Trees
Lesson 7 Trees
Lesson 7: Trees
Prepared by: Ms. Kimberly Reyes
Trees
Tree represents the nodes connected by edges.
We will discuss binary tree or binary search tree
specifically.
“
Binary Tree is a special data structure used
for data storage purposes. A binary tree has
a special condition that each node can have
a maximum of two children. A binary tree
has the benefits of both an ordered array
and a linked list as search is as quick as in a
sorted array and insertion or deletion
operation are as fast as in linked list.
Binary Tree
Important Terms
Following are the important terms with respect to
tree.
Path − Path refers to the sequence of nodes along the
edges of a tree.
Root − The node at the top of the tree is called root. There
is only one root per tree and one path from the root node
to any node.
Parent − Any node except the root node has one edge
upward to a node called parent.
Leaf − The node which does not have any child node is
called the leaf node.
Subtree − Subtree represents the descendants of a node.
In-order Traversal
Pre-order Traversal
Post-order Traversal