2
Most read
15
Most read
16
Most read
Expression tree
Nagajothi N
1 M.Sc., IT
1
Objectives
 What is expression tree
 What are expressions in data structures?
 What kind of expression tree
 What type of data structure is tree?
 Construction of expression tree
 Traversal of expression tree
 Algebraic expression tree
 Boolean expression tree
2
What is expression tree
 A binary expression tree is a specific kind of a
binary tree used to represent expressions. ..
 These trees can represent expressions that
contain both unary and binary operators
 Each node of a binary tree, and hence of a binary
expression tree, has zero, one, or two children.
3
What are expressions in data structures?
 An expression is a collection of operators and
operands that represents a specific value.
 operator is a symbol which performs a
particular task like arithmetic operation or
logical operation or conditional operation etc.,
 Operands are the values on which the
operators can perform the task
4
Operators
Operands
5
There are three kinds of expressions
 An arithmetic expression evaluates to a single
arithmetic value.(x, x 2, xy, or 3xy 2,)
 A character expression evaluates to a single
value of type character.
 A logical or relational expression evaluates to a
single logical value(TRUE or FALSE)
6
What type of data structure is tree?
 A tree is a hierarchical data structure which can
represent relationships between different
nodes
7
Tree structure
8
Construction of expression tree
 Now For constructing an expression tree
we use a stack.
 If a character is an operator pop two values
from the stack make them its child and push
the current node again
9
example
10
Algebraic expression
 Algebraic expression trees represent
expressions that contain numbers,variables,
and unary and binary operators.
 Some of the common operators are ×
(multiplication), ÷ (division), + (addition), −
(subtraction), ^ (exponentiation), and -
(negation)
11
Boolean expressions
 Boolean expressions use true and false as
constant values, and the operators
include (AND), (OR), (NOT).
12
Traversal of expression tree
infix
expression
Postfix
expression
Prefix
expression
13
infix expression
 X + Y. Operators are written in-between their
operands
 An expression such as A * ( B + C ) / D is usually
taken to mean something like: "First add B and
C together, then multiply the result by A, then
divide by D to give the final answer."
14
example
15
Postfix expression
 X Y + Operators are written after their
operands. The infix expression given above is
equivalent to A B C + * D /
16
example
17
Prefix expression
 + X Y Operators are written before their
operands. The expressions given above are
equivalent to / * A + B C D
18
example
19
Thankyou !
20

More Related Content

PPTX
String C Programming
PPTX
Tree Traversal
PPTX
Presentation on array
PPTX
Programming in c Arrays
PPTX
PPT
Strings
PPT
Data Structure: TREES
PPTX
concept of Array, 1D & 2D array
String C Programming
Tree Traversal
Presentation on array
Programming in c Arrays
Strings
Data Structure: TREES
concept of Array, 1D & 2D array

What's hot (20)

PPTX
Python dictionary
PPTX
Two dimensional arrays
PPT
Two dimensional array
PPTX
Array in c programming
PPTX
Array ppt
PPTX
Threaded Binary Tree.pptx
PPTX
trees in data structure
PPTX
Pointer in c program
PPTX
PPT
Pointers C programming
PPTX
Presentation on matrix
PPT
1.1 binary tree
PDF
Dld lecture module 02
PPT
Array in c
PPT
RECURSION IN C
PPTX
Data structure , stack , queue
PDF
Keywords, identifiers ,datatypes in C++
PPTX
Arrays in c
PPT
Data Structures and Algorithm Analysis
PPTX
Data structures and algorithms
Python dictionary
Two dimensional arrays
Two dimensional array
Array in c programming
Array ppt
Threaded Binary Tree.pptx
trees in data structure
Pointer in c program
Pointers C programming
Presentation on matrix
1.1 binary tree
Dld lecture module 02
Array in c
RECURSION IN C
Data structure , stack , queue
Keywords, identifiers ,datatypes in C++
Arrays in c
Data Structures and Algorithm Analysis
Data structures and algorithms
Ad

Similar to Expression tree (20)

PPTX
Python.pptx
PDF
I am kind of confused about quantifiers. I am not sure how to transl.pdf
PPTX
Relational Data Model Introduction
PPTX
ChapterTwoandThreefnfgncvdjhgjshgjdlahgjlhglj.pptx
PDF
Data Handling_XI_Finall for grade 11 cbse board
PPTX
RELATIONAL MODEL CONCEPTS.pptx with good explanation
PDF
+2 Computer Science - Volume II Notes
PDF
Iipm chapter 1
PDF
Iipm chapter 1
PPTX
LANGUAGE-OF-RELATIONS-AND-FUNCTIONS.pptx
PDF
Chapter1.pdf this is the first chapter of the book, will share
PPT
java_lect_03-2.ppt
DOCX
Special Topics on Functions, Sequences, and Series MAT117 .docx
PPTX
Relations & Functions.pptx
PPTX
ERD.pptx
PPT
Entity Relationship Diagram
PDF
Unit-II DBMS presentation for students.pdf
PPTX
UNIT-2 Relation algebra&RelationalCalculus.pptx
PDF
Programming in Scala - Lecture Three
PDF
2 data types and operators in r
Python.pptx
I am kind of confused about quantifiers. I am not sure how to transl.pdf
Relational Data Model Introduction
ChapterTwoandThreefnfgncvdjhgjshgjdlahgjlhglj.pptx
Data Handling_XI_Finall for grade 11 cbse board
RELATIONAL MODEL CONCEPTS.pptx with good explanation
+2 Computer Science - Volume II Notes
Iipm chapter 1
Iipm chapter 1
LANGUAGE-OF-RELATIONS-AND-FUNCTIONS.pptx
Chapter1.pdf this is the first chapter of the book, will share
java_lect_03-2.ppt
Special Topics on Functions, Sequences, and Series MAT117 .docx
Relations & Functions.pptx
ERD.pptx
Entity Relationship Diagram
Unit-II DBMS presentation for students.pdf
UNIT-2 Relation algebra&RelationalCalculus.pptx
Programming in Scala - Lecture Three
2 data types and operators in r
Ad

More from NagajothiN1 (11)

PPTX
Apache Oozie
PPTX
mobile jammer
PPTX
Version control libraries
PPTX
Designing data marts
PPTX
8 queen problem
PPTX
8 queen problem
PPTX
Over view of data structures
PPTX
Over view of data structures
PPTX
Over view of data structures
PPTX
Over view of data structures
PPTX
Over view of data structures
Apache Oozie
mobile jammer
Version control libraries
Designing data marts
8 queen problem
8 queen problem
Over view of data structures
Over view of data structures
Over view of data structures
Over view of data structures
Over view of data structures

Recently uploaded (20)

PPTX
20th Century Theater, Methods, History.pptx
PPTX
Unit 4 Computer Architecture Multicore Processor.pptx
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PDF
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
PDF
Weekly quiz Compilation Jan -July 25.pdf
PDF
What if we spent less time fighting change, and more time building what’s rig...
PDF
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
PPTX
TNA_Presentation-1-Final(SAVE)) (1).pptx
PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
PDF
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PDF
LDMMIA Reiki Yoga Finals Review Spring Summer
PDF
Hazard Identification & Risk Assessment .pdf
PDF
Practical Manual AGRO-233 Principles and Practices of Natural Farming
PPTX
History, Philosophy and sociology of education (1).pptx
PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
PDF
Empowerment Technology for Senior High School Guide
PDF
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
20th Century Theater, Methods, History.pptx
Unit 4 Computer Architecture Multicore Processor.pptx
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
Paper A Mock Exam 9_ Attempt review.pdf.
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
Weekly quiz Compilation Jan -July 25.pdf
What if we spent less time fighting change, and more time building what’s rig...
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
TNA_Presentation-1-Final(SAVE)) (1).pptx
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
LDMMIA Reiki Yoga Finals Review Spring Summer
Hazard Identification & Risk Assessment .pdf
Practical Manual AGRO-233 Principles and Practices of Natural Farming
History, Philosophy and sociology of education (1).pptx
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
Empowerment Technology for Senior High School Guide
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf

Expression tree

  • 2. Objectives  What is expression tree  What are expressions in data structures?  What kind of expression tree  What type of data structure is tree?  Construction of expression tree  Traversal of expression tree  Algebraic expression tree  Boolean expression tree 2
  • 3. What is expression tree  A binary expression tree is a specific kind of a binary tree used to represent expressions. ..  These trees can represent expressions that contain both unary and binary operators  Each node of a binary tree, and hence of a binary expression tree, has zero, one, or two children. 3
  • 4. What are expressions in data structures?  An expression is a collection of operators and operands that represents a specific value.  operator is a symbol which performs a particular task like arithmetic operation or logical operation or conditional operation etc.,  Operands are the values on which the operators can perform the task 4
  • 6. There are three kinds of expressions  An arithmetic expression evaluates to a single arithmetic value.(x, x 2, xy, or 3xy 2,)  A character expression evaluates to a single value of type character.  A logical or relational expression evaluates to a single logical value(TRUE or FALSE) 6
  • 7. What type of data structure is tree?  A tree is a hierarchical data structure which can represent relationships between different nodes 7
  • 9. Construction of expression tree  Now For constructing an expression tree we use a stack.  If a character is an operator pop two values from the stack make them its child and push the current node again 9
  • 11. Algebraic expression  Algebraic expression trees represent expressions that contain numbers,variables, and unary and binary operators.  Some of the common operators are × (multiplication), ÷ (division), + (addition), − (subtraction), ^ (exponentiation), and - (negation) 11
  • 12. Boolean expressions  Boolean expressions use true and false as constant values, and the operators include (AND), (OR), (NOT). 12
  • 13. Traversal of expression tree infix expression Postfix expression Prefix expression 13
  • 14. infix expression  X + Y. Operators are written in-between their operands  An expression such as A * ( B + C ) / D is usually taken to mean something like: "First add B and C together, then multiply the result by A, then divide by D to give the final answer." 14
  • 16. Postfix expression  X Y + Operators are written after their operands. The infix expression given above is equivalent to A B C + * D / 16
  • 18. Prefix expression  + X Y Operators are written before their operands. The expressions given above are equivalent to / * A + B C D 18