SlideShare a Scribd company logo
Data Structures
Presentation By:
Amna Iqbal
Amna Muzzafar
Asma Iqbal
Faiza Zahid
Maryam Tariq
Sumaira
Shabana kausar
Shamsa
Tahseen Fatima
Zeerak
2
An application of binary trees
Binary Expression Trees
3
A special kind of binary tree in which:
• The leaves of a binary expression tree are operands, such as
constants or variable names , and the other nodes contain
operators
• Each leaf node contains a single operand
• Each nonleaf node contains a single binary operator
• The left and right subtrees of an operator node represent
subexpressions that must be evaluated before applying the
operator at the root of the subtree.
A Binary Expression Tree is . . .
4
A Binary Expression Tree
What value does it have?
( 4 + 2 ) * 3 = 18
‘*’
‘+’
‘4’
‘3’
‘2’
5
A Four-Level Binary Expression
‘*’
‘-’
‘8’ ‘5’
‘/’
‘+’
‘4’
‘3’
‘2’
Expression Tree Examples
Inorder Traversal ResultExpression TreeExpression
a + 3(a+3)
3+4*5-9+63+(4*5-(9+6))
log xlog(x)
n !n!
+
3a
+
-3
*
54
+
69
log
x
!
n
Infix Expressions
• When you write an arithmetic expression such as
B * C, the form of the expression provides you
with information so that you can interpret it
correctly. In this case we know that the variable B
is being multiplied by the variable C since the
multiplication operator * appears between them
in the expression This type of notation is referred
to as infix since the operator is in between the two
operands that it is working on.
7
Prefix Expressions
• Prefix expression notation requires that all
operators precede the two operands that
they work on.
• A + B * C would be written as +A*BC in
prefix. The multiplication operator comes
immediately before the operands B and C,
denoting that * has precedence over +. The
addition operator then appears before the A
and the result of the multiplication.
8
Postfix Expressions
• Postfix requires that its operators come after
the corresponding operands.
• A + B * C would be written as ABC*+ in postfix.
The multiplication operator appears
immediately after the B and the C, denoting
that * has precedence, with + coming after.
9
Examples of Infix, Prefix, and
Postfix
10
Infix Expression Prefix Expression Postfix Expression
A + B + A B A B +
A + B * C + A * B C A B C * +
11
Easy to generate the infix, prefix, postfix
expressions (how?)
Infix: ( ( 8 - 5 ) * ( ( 4 + 2 ) / 3 ) )
Prefix: * - 8 5 / + 4 2 3
Postfix: 8 5 - 4 2 + 3 / *
‘*’
‘-’
‘8’ ‘5’
‘/’
‘+’
‘4’
‘3’
‘2’
Infix to Postfix conversion (manual)
• An Infix to Postfix manual conversion algorithm is:
1. Completely parenthesize the infix expression according to order of priority
you want.
2. Move each operator to its corresponding right parenthesis.
3. Remove all parentheses.
• Examples:
3 + 4 * 5 (3 + (4 * 5) ) 3 4 5 * +
a / b ^ c – d * e – a * c ^ 3 ^ 4 a b c ^ / d e * a c 3 4 ^ ^ * - -
((a / (b ^ c)) – ((d * e) – (a * (c ^ (3 ^ 4) ) ) ) )
Using normal mathematical
operator precedence
Not using normal mathematical
operator precedence
13
Levels Indicate Precedence
The levels of the nodes in the tree indicate their
relative precedence of evaluation (we do not need
parentheses to indicate precedence).
Each operator has a precedence level. Operators of
higher precedence are used before operators of lower
precedence
Operations at higher levels of the tree are
evaluated later than those below them.
The operation at the root is always the last
operation performed.
Tree Traversal
• A tree traversal is a specific order in
which to trace the nodes of a tree.
14
Types Of Tree Traversal
• There are 3 common types of tree
traversals.
• In-order.
• 2. Pre-order.
• 3. Post-order.
15
16
Inorder Traversal:
In-order: left, root, right (A + H) / (M - Y)
‘/’
‘+’
‘A’ ‘H’
‘-’
‘M’ ‘Y’
tree
Print left subtree first Print right subtree last
Print second
17
Preorder Traversal:
Pre-order: root, left, right / + A H - M Y
‘/’
‘+’
‘A’ ‘H’
‘-’
‘M’ ‘Y’
tree
Print left subtree second Print right subtree last
Print first
18
‘/’
‘+’
‘A’ ‘H’
‘-’
‘M’ ‘Y’
tree
Print left subtree first Print right subtree second
Print last
Postorder Traversal:
Post-order: left, right, root A H + M Y - /
19
Building a Binary Expression Tree from an
expression in prefix notation
• Insert new nodes, each time moving to the left until
an operand has been inserted.
• Backtrack to the last operator, and put the next node
to its right.
• Continue in the same pattern.
Algorithm for Expression tree
Algorithm for Expression tree
1 Scan expression from left to right until end of string
2 If (symbol = operand)
P= new node
P.data= symbol
Push(P)
Else
Ptr1= Pop()
Ptr2= Pop()
P= new node
P.data= symbol
P.Lchild= Ptr2
P.Rchild=Ptr1
Push(P)
3 Exit
How to scan an expression
1. While there are still tokens to be read in,
1.1 Get the next token.
1.2 If the token is:
1.2.1 A number: push it onto the value stack.
1.2.2 A variable: get its value, and push onto the value stack.
1.2.3 A left parenthesis: push it onto the operator stack.
1.2.4 A right parenthesis:
1 While the thing on top of the operator stack is not a
left parenthesis,
1 Pop the operator from the operator stack.
2 Pop the value stack twice, getting two operands.
3 Apply the operator to the operands, in the correct order.
4 Push the result onto the value stack.
2 Pop the left parenthesis from the operator stack, and discard it.
How to scan an expression
1.2.5 An operator (call it thisOp):
1 While the operator stack is not empty, and the top
thing on the
operator stack has the same or greater precedence as
thisOp,
1 Pop the operator from the operator stack.
2 Pop the value stack twice, getting two operands.
3 Apply the operator to the operands, in the correct
order.
4 Push the result onto the value stack.
2 Push thisOp onto the operator stack.
How to scan an expression
2. While the operator stack is not empty,
1 Pop the operator from the operator stack.
2 Pop the value stack twice, getting two operands.
3 Apply the operator to the operands, in the correct
order.
4 Push the result onto the value stack.
3. At this point the operator stack should be empty,
and the value
stack should have only one value in it, which is the
final result

More Related Content

What's hot

Tree traversal techniques
Tree traversal techniquesTree traversal techniques
Tree traversal techniques
Syed Zaid Irshad
 
Binary tree
Binary treeBinary tree
Binary tree
Rajendran
 
Stacks
StacksStacks
Stacks
sweta dargad
 
single linked list
single linked listsingle linked list
single linked list
Sathasivam Rangasamy
 
Lec 17 heap data structure
Lec 17 heap data structureLec 17 heap data structure
Lec 17 heap data structure
Sajid Marwat
 
Graph traversals in Data Structures
Graph traversals in Data StructuresGraph traversals in Data Structures
Graph traversals in Data Structures
Anandhasilambarasan D
 
Binary search tree(bst)
Binary search tree(bst)Binary search tree(bst)
Binary search tree(bst)
Hossain Md Shakhawat
 
Heap tree
Heap treeHeap tree
Heap tree
Shankar Bishnoi
 
Heap sort
Heap sortHeap sort
Heap sort
Mohd Arif
 
Threaded Binary Tree.pptx
Threaded Binary Tree.pptxThreaded Binary Tree.pptx
Threaded Binary Tree.pptx
pavankumarjakkepalli
 
1.5 binary search tree
1.5 binary search tree1.5 binary search tree
1.5 binary search tree
Krish_ver2
 
Priority Queue in Data Structure
Priority Queue in Data StructurePriority Queue in Data Structure
Priority Queue in Data Structure
Meghaj Mallick
 
Queue in Data Structure
Queue in Data StructureQueue in Data Structure
Queue in Data Structure
Muhazzab Chouhadry
 
Sparse matrix and its representation data structure
Sparse matrix and its representation data structureSparse matrix and its representation data structure
Sparse matrix and its representation data structure
Vardhil Patel
 
Computer notes - Expression Tree
Computer notes - Expression TreeComputer notes - Expression Tree
Computer notes - Expression Tree
ecomputernotes
 
Tree in data structure
Tree in data structureTree in data structure
Tree in data structure
Äshïsh Jäïn
 
Stack
StackStack
stack & queue
stack & queuestack & queue
stack & queue
manju rani
 
Data Structure (Tree)
Data Structure (Tree)Data Structure (Tree)
Data Structure (Tree)
Adam Mukharil Bachtiar
 
Data structure by Digvijay
Data structure by DigvijayData structure by Digvijay
Data structure by Digvijay
Digvijay Singh Karakoti
 

What's hot (20)

Tree traversal techniques
Tree traversal techniquesTree traversal techniques
Tree traversal techniques
 
Binary tree
Binary treeBinary tree
Binary tree
 
Stacks
StacksStacks
Stacks
 
single linked list
single linked listsingle linked list
single linked list
 
Lec 17 heap data structure
Lec 17 heap data structureLec 17 heap data structure
Lec 17 heap data structure
 
Graph traversals in Data Structures
Graph traversals in Data StructuresGraph traversals in Data Structures
Graph traversals in Data Structures
 
Binary search tree(bst)
Binary search tree(bst)Binary search tree(bst)
Binary search tree(bst)
 
Heap tree
Heap treeHeap tree
Heap tree
 
Heap sort
Heap sortHeap sort
Heap sort
 
Threaded Binary Tree.pptx
Threaded Binary Tree.pptxThreaded Binary Tree.pptx
Threaded Binary Tree.pptx
 
1.5 binary search tree
1.5 binary search tree1.5 binary search tree
1.5 binary search tree
 
Priority Queue in Data Structure
Priority Queue in Data StructurePriority Queue in Data Structure
Priority Queue in Data Structure
 
Queue in Data Structure
Queue in Data StructureQueue in Data Structure
Queue in Data Structure
 
Sparse matrix and its representation data structure
Sparse matrix and its representation data structureSparse matrix and its representation data structure
Sparse matrix and its representation data structure
 
Computer notes - Expression Tree
Computer notes - Expression TreeComputer notes - Expression Tree
Computer notes - Expression Tree
 
Tree in data structure
Tree in data structureTree in data structure
Tree in data structure
 
Stack
StackStack
Stack
 
stack & queue
stack & queuestack & queue
stack & queue
 
Data Structure (Tree)
Data Structure (Tree)Data Structure (Tree)
Data Structure (Tree)
 
Data structure by Digvijay
Data structure by DigvijayData structure by Digvijay
Data structure by Digvijay
 

Viewers also liked

1.4 expression tree
1.4 expression tree  1.4 expression tree
1.4 expression tree
Krish_ver2
 
Implementation of trees
Implementation of trees Implementation of trees
Implementation of trees
Mubashar Mehmood
 
Infix to Prefix (Conversion, Evaluation, Code)
Infix to Prefix (Conversion, Evaluation, Code)Infix to Prefix (Conversion, Evaluation, Code)
Infix to Prefix (Conversion, Evaluation, Code)
Ahmed Khateeb
 
Expression trees
Expression treesExpression trees
Expression trees
Salman Vadsarya
 
Lec21
Lec21Lec21
B trees in Data Structure
B trees in Data StructureB trees in Data Structure
B trees in Data Structure
Anuj Modi
 
Graph theory
Graph theoryGraph theory
Graph theory
Nitesh Nayal
 
Logic Gates O level Past Papers questions
Logic Gates O level Past Papers questionsLogic Gates O level Past Papers questions
Logic Gates O level Past Papers questions
cvcvvc
 
Notasi prefix infix-postifx- expression tree
Notasi prefix infix-postifx- expression treeNotasi prefix infix-postifx- expression tree
Notasi prefix infix-postifx- expression tree
Acomic Comic
 
Unit – vi tree
Unit – vi   treeUnit – vi   tree
Unit – vi tree
Tribhuvan University
 
DATA STRUCTURES AND ALGORITHMS UNIT-3 TREES PREPARED BY M V BRAHMANANDA REDDY
DATA STRUCTURES AND ALGORITHMS UNIT-3 TREES PREPARED BY M V BRAHMANANDA REDDYDATA STRUCTURES AND ALGORITHMS UNIT-3 TREES PREPARED BY M V BRAHMANANDA REDDY
DATA STRUCTURES AND ALGORITHMS UNIT-3 TREES PREPARED BY M V BRAHMANANDA REDDY
Malikireddy Bramhananda Reddy
 
Data structures 3
Data structures 3Data structures 3
Data structures 3
Parthipan Parthi
 
Shunting yard algo
Shunting yard algoShunting yard algo
Shunting yard algo
Toufiq Akbar
 
Stack and queue -polish notations
Stack and queue -polish notationsStack and queue -polish notations
Stack and queue -polish notations
jyoti_lakhani
 
Trees
TreesTrees
Trees (slides)
Trees (slides)Trees (slides)
Trees (slides)
IIUM
 
Open course(programming languages) 20150225
Open course(programming languages) 20150225Open course(programming languages) 20150225
Open course(programming languages) 20150225
JangChulho
 
Trees
Trees Trees
Trees
Gaditek
 
Discrete Mathematics Tree
Discrete Mathematics  TreeDiscrete Mathematics  Tree
Discrete Mathematics Tree
Masud Parvaze
 
Evaluation Theory Tree: Evaluation Approaches
Evaluation Theory Tree: Evaluation ApproachesEvaluation Theory Tree: Evaluation Approaches
Evaluation Theory Tree: Evaluation Approaches
Innovation Network
 

Viewers also liked (20)

1.4 expression tree
1.4 expression tree  1.4 expression tree
1.4 expression tree
 
Implementation of trees
Implementation of trees Implementation of trees
Implementation of trees
 
Infix to Prefix (Conversion, Evaluation, Code)
Infix to Prefix (Conversion, Evaluation, Code)Infix to Prefix (Conversion, Evaluation, Code)
Infix to Prefix (Conversion, Evaluation, Code)
 
Expression trees
Expression treesExpression trees
Expression trees
 
Lec21
Lec21Lec21
Lec21
 
B trees in Data Structure
B trees in Data StructureB trees in Data Structure
B trees in Data Structure
 
Graph theory
Graph theoryGraph theory
Graph theory
 
Logic Gates O level Past Papers questions
Logic Gates O level Past Papers questionsLogic Gates O level Past Papers questions
Logic Gates O level Past Papers questions
 
Notasi prefix infix-postifx- expression tree
Notasi prefix infix-postifx- expression treeNotasi prefix infix-postifx- expression tree
Notasi prefix infix-postifx- expression tree
 
Unit – vi tree
Unit – vi   treeUnit – vi   tree
Unit – vi tree
 
DATA STRUCTURES AND ALGORITHMS UNIT-3 TREES PREPARED BY M V BRAHMANANDA REDDY
DATA STRUCTURES AND ALGORITHMS UNIT-3 TREES PREPARED BY M V BRAHMANANDA REDDYDATA STRUCTURES AND ALGORITHMS UNIT-3 TREES PREPARED BY M V BRAHMANANDA REDDY
DATA STRUCTURES AND ALGORITHMS UNIT-3 TREES PREPARED BY M V BRAHMANANDA REDDY
 
Data structures 3
Data structures 3Data structures 3
Data structures 3
 
Shunting yard algo
Shunting yard algoShunting yard algo
Shunting yard algo
 
Stack and queue -polish notations
Stack and queue -polish notationsStack and queue -polish notations
Stack and queue -polish notations
 
Trees
TreesTrees
Trees
 
Trees (slides)
Trees (slides)Trees (slides)
Trees (slides)
 
Open course(programming languages) 20150225
Open course(programming languages) 20150225Open course(programming languages) 20150225
Open course(programming languages) 20150225
 
Trees
Trees Trees
Trees
 
Discrete Mathematics Tree
Discrete Mathematics  TreeDiscrete Mathematics  Tree
Discrete Mathematics Tree
 
Evaluation Theory Tree: Evaluation Approaches
Evaluation Theory Tree: Evaluation ApproachesEvaluation Theory Tree: Evaluation Approaches
Evaluation Theory Tree: Evaluation Approaches
 

Similar to Binary expression tree

Stack application
Stack applicationStack application
Stack application
Ravi solanki
 
MO 2020 DS Stacks 3 AB.ppt
MO 2020 DS Stacks 3 AB.pptMO 2020 DS Stacks 3 AB.ppt
MO 2020 DS Stacks 3 AB.ppt
shashankbhadouria4
 
Unit 2 application of stack
Unit 2  application of stack Unit 2  application of stack
Unit 2 application of stack
LavanyaJ28
 
DS-UNIT 3 FINAL.pptx
DS-UNIT 3 FINAL.pptxDS-UNIT 3 FINAL.pptx
DS-UNIT 3 FINAL.pptx
prakashvs7
 
DS UNIT1_STACKS.pptx
DS UNIT1_STACKS.pptxDS UNIT1_STACKS.pptx
DS UNIT1_STACKS.pptx
VeerannaKotagi1
 
Stack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptxStack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptx
chandankumar364348
 
Unit I - Evaluation of expression
Unit I - Evaluation of expressionUnit I - Evaluation of expression
Unit I - Evaluation of expression
DrkhanchanaR
 
Unit II - LINEAR DATA STRUCTURES
Unit II -  LINEAR DATA STRUCTURESUnit II -  LINEAR DATA STRUCTURES
Unit II - LINEAR DATA STRUCTURES
Usha Mahalingam
 
SPL 6 | Operators in C
SPL 6 | Operators in CSPL 6 | Operators in C
SPL 6 | Operators in C
Mohammad Imam Hossain
 
Infix-Postfix expression conversion
Infix-Postfix expression conversionInfix-Postfix expression conversion
Infix-Postfix expression conversion
Rashmiranja625
 
3. Syntax Analyzer.pptx
3. Syntax Analyzer.pptx3. Syntax Analyzer.pptx
3. Syntax Analyzer.pptx
Mattupallipardhu
 
Unit 3 Stacks and Queues.pptx
Unit 3 Stacks and Queues.pptxUnit 3 Stacks and Queues.pptx
Unit 3 Stacks and Queues.pptx
Yogesh Pawar
 
Application of Stack For Expression Evaluation by Prakash Zodge DSY 41.pptx
Application of Stack For Expression Evaluation by Prakash Zodge DSY 41.pptxApplication of Stack For Expression Evaluation by Prakash Zodge DSY 41.pptx
Application of Stack For Expression Evaluation by Prakash Zodge DSY 41.pptx
Prakash Zodge
 
Evaluation of postfix expression
Evaluation of postfix expressionEvaluation of postfix expression
Evaluation of postfix expression
Akhil Ahuja
 
Parsing
ParsingParsing
Parsing
khush_boo31
 
2. Stack. Write a program that uses the stack class (you can use.pdf
2. Stack. Write a program that uses the stack class (you can use.pdf2. Stack. Write a program that uses the stack class (you can use.pdf
2. Stack. Write a program that uses the stack class (you can use.pdf
aniarihant
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
Jasleen Kaur (Chandigarh University)
 
The concept of stack is extremely important in computer science and .pdf
The concept of stack is extremely important in computer science and .pdfThe concept of stack is extremely important in computer science and .pdf
The concept of stack is extremely important in computer science and .pdf
arihantsherwani
 
Unit 4. Operators and Expression
Unit 4. Operators and Expression  Unit 4. Operators and Expression
Unit 4. Operators and Expression
Ashim Lamichhane
 
STACK USING LISTS.pptx
STACK USING LISTS.pptxSTACK USING LISTS.pptx
STACK USING LISTS.pptx
Baby81727
 

Similar to Binary expression tree (20)

Stack application
Stack applicationStack application
Stack application
 
MO 2020 DS Stacks 3 AB.ppt
MO 2020 DS Stacks 3 AB.pptMO 2020 DS Stacks 3 AB.ppt
MO 2020 DS Stacks 3 AB.ppt
 
Unit 2 application of stack
Unit 2  application of stack Unit 2  application of stack
Unit 2 application of stack
 
DS-UNIT 3 FINAL.pptx
DS-UNIT 3 FINAL.pptxDS-UNIT 3 FINAL.pptx
DS-UNIT 3 FINAL.pptx
 
DS UNIT1_STACKS.pptx
DS UNIT1_STACKS.pptxDS UNIT1_STACKS.pptx
DS UNIT1_STACKS.pptx
 
Stack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptxStack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptx
 
Unit I - Evaluation of expression
Unit I - Evaluation of expressionUnit I - Evaluation of expression
Unit I - Evaluation of expression
 
Unit II - LINEAR DATA STRUCTURES
Unit II -  LINEAR DATA STRUCTURESUnit II -  LINEAR DATA STRUCTURES
Unit II - LINEAR DATA STRUCTURES
 
SPL 6 | Operators in C
SPL 6 | Operators in CSPL 6 | Operators in C
SPL 6 | Operators in C
 
Infix-Postfix expression conversion
Infix-Postfix expression conversionInfix-Postfix expression conversion
Infix-Postfix expression conversion
 
3. Syntax Analyzer.pptx
3. Syntax Analyzer.pptx3. Syntax Analyzer.pptx
3. Syntax Analyzer.pptx
 
Unit 3 Stacks and Queues.pptx
Unit 3 Stacks and Queues.pptxUnit 3 Stacks and Queues.pptx
Unit 3 Stacks and Queues.pptx
 
Application of Stack For Expression Evaluation by Prakash Zodge DSY 41.pptx
Application of Stack For Expression Evaluation by Prakash Zodge DSY 41.pptxApplication of Stack For Expression Evaluation by Prakash Zodge DSY 41.pptx
Application of Stack For Expression Evaluation by Prakash Zodge DSY 41.pptx
 
Evaluation of postfix expression
Evaluation of postfix expressionEvaluation of postfix expression
Evaluation of postfix expression
 
Parsing
ParsingParsing
Parsing
 
2. Stack. Write a program that uses the stack class (you can use.pdf
2. Stack. Write a program that uses the stack class (you can use.pdf2. Stack. Write a program that uses the stack class (you can use.pdf
2. Stack. Write a program that uses the stack class (you can use.pdf
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
 
The concept of stack is extremely important in computer science and .pdf
The concept of stack is extremely important in computer science and .pdfThe concept of stack is extremely important in computer science and .pdf
The concept of stack is extremely important in computer science and .pdf
 
Unit 4. Operators and Expression
Unit 4. Operators and Expression  Unit 4. Operators and Expression
Unit 4. Operators and Expression
 
STACK USING LISTS.pptx
STACK USING LISTS.pptxSTACK USING LISTS.pptx
STACK USING LISTS.pptx
 

Recently uploaded

Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
abbyasa1014
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
171ticu
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
kandramariana6
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
camseq
 
New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
wisnuprabawa3
 
Casting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdfCasting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdf
zubairahmad848137
 
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEMTIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
HODECEDSIET
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
VICTOR MAESTRE RAMIREZ
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
sachin chaurasia
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
Hitesh Mohapatra
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
University of Maribor
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
IJNSA Journal
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
Rahul
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
Dr Ramhari Poudyal
 
Question paper of renewable energy sources
Question paper of renewable energy sourcesQuestion paper of renewable energy sources
Question paper of renewable energy sources
mahammadsalmanmech
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
NidhalKahouli2
 
Engine Lubrication performance System.pdf
Engine Lubrication performance System.pdfEngine Lubrication performance System.pdf
Engine Lubrication performance System.pdf
mamamaam477
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
RadiNasr
 
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
KrishnaveniKrishnara1
 
Textile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdfTextile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdf
NazakatAliKhoso2
 

Recently uploaded (20)

Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
 
New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
 
Casting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdfCasting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdf
 
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEMTIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
 
Question paper of renewable energy sources
Question paper of renewable energy sourcesQuestion paper of renewable energy sources
Question paper of renewable energy sources
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
 
Engine Lubrication performance System.pdf
Engine Lubrication performance System.pdfEngine Lubrication performance System.pdf
Engine Lubrication performance System.pdf
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
 
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
 
Textile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdfTextile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdf
 

Binary expression tree

  • 1. Data Structures Presentation By: Amna Iqbal Amna Muzzafar Asma Iqbal Faiza Zahid Maryam Tariq Sumaira Shabana kausar Shamsa Tahseen Fatima Zeerak
  • 2. 2 An application of binary trees Binary Expression Trees
  • 3. 3 A special kind of binary tree in which: • The leaves of a binary expression tree are operands, such as constants or variable names , and the other nodes contain operators • Each leaf node contains a single operand • Each nonleaf node contains a single binary operator • The left and right subtrees of an operator node represent subexpressions that must be evaluated before applying the operator at the root of the subtree. A Binary Expression Tree is . . .
  • 4. 4 A Binary Expression Tree What value does it have? ( 4 + 2 ) * 3 = 18 ‘*’ ‘+’ ‘4’ ‘3’ ‘2’
  • 5. 5 A Four-Level Binary Expression ‘*’ ‘-’ ‘8’ ‘5’ ‘/’ ‘+’ ‘4’ ‘3’ ‘2’
  • 6. Expression Tree Examples Inorder Traversal ResultExpression TreeExpression a + 3(a+3) 3+4*5-9+63+(4*5-(9+6)) log xlog(x) n !n! + 3a + -3 * 54 + 69 log x ! n
  • 7. Infix Expressions • When you write an arithmetic expression such as B * C, the form of the expression provides you with information so that you can interpret it correctly. In this case we know that the variable B is being multiplied by the variable C since the multiplication operator * appears between them in the expression This type of notation is referred to as infix since the operator is in between the two operands that it is working on. 7
  • 8. Prefix Expressions • Prefix expression notation requires that all operators precede the two operands that they work on. • A + B * C would be written as +A*BC in prefix. The multiplication operator comes immediately before the operands B and C, denoting that * has precedence over +. The addition operator then appears before the A and the result of the multiplication. 8
  • 9. Postfix Expressions • Postfix requires that its operators come after the corresponding operands. • A + B * C would be written as ABC*+ in postfix. The multiplication operator appears immediately after the B and the C, denoting that * has precedence, with + coming after. 9
  • 10. Examples of Infix, Prefix, and Postfix 10 Infix Expression Prefix Expression Postfix Expression A + B + A B A B + A + B * C + A * B C A B C * +
  • 11. 11 Easy to generate the infix, prefix, postfix expressions (how?) Infix: ( ( 8 - 5 ) * ( ( 4 + 2 ) / 3 ) ) Prefix: * - 8 5 / + 4 2 3 Postfix: 8 5 - 4 2 + 3 / * ‘*’ ‘-’ ‘8’ ‘5’ ‘/’ ‘+’ ‘4’ ‘3’ ‘2’
  • 12. Infix to Postfix conversion (manual) • An Infix to Postfix manual conversion algorithm is: 1. Completely parenthesize the infix expression according to order of priority you want. 2. Move each operator to its corresponding right parenthesis. 3. Remove all parentheses. • Examples: 3 + 4 * 5 (3 + (4 * 5) ) 3 4 5 * + a / b ^ c – d * e – a * c ^ 3 ^ 4 a b c ^ / d e * a c 3 4 ^ ^ * - - ((a / (b ^ c)) – ((d * e) – (a * (c ^ (3 ^ 4) ) ) ) ) Using normal mathematical operator precedence Not using normal mathematical operator precedence
  • 13. 13 Levels Indicate Precedence The levels of the nodes in the tree indicate their relative precedence of evaluation (we do not need parentheses to indicate precedence). Each operator has a precedence level. Operators of higher precedence are used before operators of lower precedence Operations at higher levels of the tree are evaluated later than those below them. The operation at the root is always the last operation performed.
  • 14. Tree Traversal • A tree traversal is a specific order in which to trace the nodes of a tree. 14
  • 15. Types Of Tree Traversal • There are 3 common types of tree traversals. • In-order. • 2. Pre-order. • 3. Post-order. 15
  • 16. 16 Inorder Traversal: In-order: left, root, right (A + H) / (M - Y) ‘/’ ‘+’ ‘A’ ‘H’ ‘-’ ‘M’ ‘Y’ tree Print left subtree first Print right subtree last Print second
  • 17. 17 Preorder Traversal: Pre-order: root, left, right / + A H - M Y ‘/’ ‘+’ ‘A’ ‘H’ ‘-’ ‘M’ ‘Y’ tree Print left subtree second Print right subtree last Print first
  • 18. 18 ‘/’ ‘+’ ‘A’ ‘H’ ‘-’ ‘M’ ‘Y’ tree Print left subtree first Print right subtree second Print last Postorder Traversal: Post-order: left, right, root A H + M Y - /
  • 19. 19 Building a Binary Expression Tree from an expression in prefix notation • Insert new nodes, each time moving to the left until an operand has been inserted. • Backtrack to the last operator, and put the next node to its right. • Continue in the same pattern.
  • 21. Algorithm for Expression tree 1 Scan expression from left to right until end of string 2 If (symbol = operand) P= new node P.data= symbol Push(P) Else Ptr1= Pop() Ptr2= Pop() P= new node P.data= symbol P.Lchild= Ptr2 P.Rchild=Ptr1 Push(P) 3 Exit
  • 22. How to scan an expression 1. While there are still tokens to be read in, 1.1 Get the next token. 1.2 If the token is: 1.2.1 A number: push it onto the value stack. 1.2.2 A variable: get its value, and push onto the value stack. 1.2.3 A left parenthesis: push it onto the operator stack. 1.2.4 A right parenthesis: 1 While the thing on top of the operator stack is not a left parenthesis, 1 Pop the operator from the operator stack. 2 Pop the value stack twice, getting two operands. 3 Apply the operator to the operands, in the correct order. 4 Push the result onto the value stack. 2 Pop the left parenthesis from the operator stack, and discard it.
  • 23. How to scan an expression 1.2.5 An operator (call it thisOp): 1 While the operator stack is not empty, and the top thing on the operator stack has the same or greater precedence as thisOp, 1 Pop the operator from the operator stack. 2 Pop the value stack twice, getting two operands. 3 Apply the operator to the operands, in the correct order. 4 Push the result onto the value stack. 2 Push thisOp onto the operator stack.
  • 24. How to scan an expression 2. While the operator stack is not empty, 1 Pop the operator from the operator stack. 2 Pop the value stack twice, getting two operands. 3 Apply the operator to the operands, in the correct order. 4 Push the result onto the value stack. 3. At this point the operator stack should be empty, and the value stack should have only one value in it, which is the final result