You are on page 1of 22

BINARY TREE

PREPARED BY: GROUP 5

MARIA CLEA MAE LEPARTO


CYPRES KHINLEY OCON
JAY LOUE PEREZ
JANICE CALOPE
AUREO MANCHA
JAY-AR LEPARTO
CONTENT

DIFFERENT
DEFINITION CONCEPT
OF BINARY OF BINARY
TREE TREE
TYPES OF
BINARY
TREE
DEFINITION OF BINARY TREE
A binary tree is a tree-type non-linear data structure
with a maximum of two children for each parent.
Every node in a binary tree has a left and right
reference along with the data element. The node at
the top of the hierarchy of a tree is called the root
.node
TYPRES OF BINARY TREE
• FULL BINARY TREE/ STRICTLY BINARY TREE
• ALMOST COMPLETE/ INCOMPLETE BINARY
TREE
• PERFECT/ COMPLETE BINARY TREE
• LEFT SKEWED BINARY TREE
• RIGHT SKEWED BINARY TREE
FULL BINARY TREE/ STRICTLY BINARY
TREE
-The full binary tree is also known as a strict binary tree.
The tree can only be considered as the full binary tree if
each node must contain either 0 or 2 children. The full
binary tree can also be defined as the tree in which each
node must contain 2 children except the leaf nodes.
ALMOST COMPLETE/ INCOMPLETE
BINARY TREE
- Every node must have two children in all the levels,
except in the last level but filled from left to right.
COMPLETE/ PERFECT BINARY TREE
- A complete binary tree is a binary tree in which all the
levels are completely filled except possibly the lowest
one, which is filled from the left.
LEFT SKEWED BINARY TREE
- Every node should have only left children.
RIGHT SKEWED BINARY TREE
- Every node should have only right children.
DIFFERENT CONCEPT OF
BINARY TREE
• BINARY TREE PRESENTATION
•BINARY TREE TRAVERSALS
• CONSTRUCTION OF ALL EXPRESSION TREE
• BINARY TREE CONSTRUCTION WITH
INORDER & PREORDER TRAVERSALS
• BINARY TREE CONSTRUCTION WITH
INORDER & POSTORDER TRAVERSALS
BINARY TREE REPRESENTATIONS
A binary tree data structure is represented using two
methods.
1. Array Representation of Binary Tree
RULES:
• Consider the root node at index 0.
• Left child is place at 2i+1 where i is position of parent
• Right child is place at 2i+2 where i is position of parent
2. Linked List Representation of Binary Tree
We use a double linked list to represent a binary tree. In a
double linked list, every node consists of three fields. First field
for storing left child address, second for storing actual data and
third for storing right child address.
BINARY TREE TRAVERSALS
Types:
1. Inorder Traversals
The left subtree is visited first, followed by the root,
and finally the right subtree in this traversal strategy.

INORDER TRAVERSAL:
( left, root, right)
2. Preorder Traversals
In this traversal method, the root node is visited first,
then the left subtree, and finally the right subtree.

PREORDER TRAVERSAL:
( root, left, right)
3. Postorder Traversals
The root node is visited last in this traversal
method, hence the name. First, we traverse the
left subtree, then the right subtree, and finally
the root node.

POSTORDER TRAVERSAL:
( left, right, root)
CONSTRUCTION OF AN EXPRESSION
TREE
The binary expression tree is a binary tree whose
leaves are operands, such as constants or variable
names, and the other nodes contain operators.

There are different types of expression formats:


1. Prefix expression
2. Infix expression and
3.Postfix expression
1. Prefix Expression
We can also evaluate prefix expression by
recursively printing out: the root, the left
expression and the right expression.
2. Infix Expression
We can produce an infix expression by recursively
printing out: the left expression,
the root, and the right expression.
3. Postfix Expression
The postfix expression can be evaluated by
recursively printing out: the left expression, the
right expression and then the root.
BINARY TREE CONSTRUCTION WITH
INORDER & PREORDER TRAVERSALS
Preorder Traversal – Finding root node
Inorder Traversals – Finding right child and left
child
BINARY TREE CONSTRUCTION WITH
INORDER & POSTORDER TRAVERSALS
Postorder Traversal – Finding root node
Inorder Traversals – Finding right child and left
child
END OF PRESENTATION
THANK YOU!!

You might also like