SlideShare a Scribd company logo
1 of 20
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

What's hot

Iipm chapter 1
Iipm chapter 1Iipm chapter 1
Iipm chapter 1
iipmff2
 
Presentation on dbms(relational calculus)
Presentation on dbms(relational calculus)Presentation on dbms(relational calculus)
Presentation on dbms(relational calculus)
yourbookworldanil
 
D I T211 Chapter 3
D I T211    Chapter 3D I T211    Chapter 3
D I T211 Chapter 3
askme
 

What's hot (18)

Sv data types and sv interface usage in uvm
Sv data types and sv interface usage in uvmSv data types and sv interface usage in uvm
Sv data types and sv interface usage in uvm
 
PPT
PPTPPT
PPT
 
Additional Relational Algebra Operations
Additional Relational Algebra OperationsAdditional Relational Algebra Operations
Additional Relational Algebra Operations
 
Fundamentals of C Programming Language
Fundamentals of C Programming LanguageFundamentals of C Programming Language
Fundamentals of C Programming Language
 
Lecture18 structurein c.ppt
Lecture18 structurein c.pptLecture18 structurein c.ppt
Lecture18 structurein c.ppt
 
Ch2
Ch2Ch2
Ch2
 
2 data types and operators in r
2 data types and operators in r2 data types and operators in r
2 data types and operators in r
 
Iipm chapter 1
Iipm chapter 1Iipm chapter 1
Iipm chapter 1
 
Dbms ER Model
Dbms ER ModelDbms ER Model
Dbms ER Model
 
1643 y є r relational calculus-1
1643 y є r  relational calculus-11643 y є r  relational calculus-1
1643 y є r relational calculus-1
 
R Datatypes
R DatatypesR Datatypes
R Datatypes
 
Presentation on dbms(relational calculus)
Presentation on dbms(relational calculus)Presentation on dbms(relational calculus)
Presentation on dbms(relational calculus)
 
Relational algebra in dbms
Relational algebra in dbmsRelational algebra in dbms
Relational algebra in dbms
 
Database Design and Normalization Techniques
Database Design and Normalization TechniquesDatabase Design and Normalization Techniques
Database Design and Normalization Techniques
 
Chapter-7 Relational Calculus
Chapter-7 Relational CalculusChapter-7 Relational Calculus
Chapter-7 Relational Calculus
 
Structure c
Structure cStructure c
Structure c
 
Structures
StructuresStructures
Structures
 
D I T211 Chapter 3
D I T211    Chapter 3D I T211    Chapter 3
D I T211 Chapter 3
 

Similar to Expression tree

I am kind of confused about quantifiers. I am not sure how to transl.pdf
I am kind of confused about quantifiers. I am not sure how to transl.pdfI am kind of confused about quantifiers. I am not sure how to transl.pdf
I am kind of confused about quantifiers. I am not sure how to transl.pdf
AMITPANCHAL154
 
Iipm chapter 1
Iipm chapter 1Iipm chapter 1
Iipm chapter 1
iipmff2
 
LANGUAGE-OF-RELATIONS-AND-FUNCTIONS.pptx
LANGUAGE-OF-RELATIONS-AND-FUNCTIONS.pptxLANGUAGE-OF-RELATIONS-AND-FUNCTIONS.pptx
LANGUAGE-OF-RELATIONS-AND-FUNCTIONS.pptx
JasonTagapanGulla
 
Special Topics on Functions, Sequences, and Series MAT117 .docx
 Special Topics on Functions, Sequences, and Series MAT117 .docx Special Topics on Functions, Sequences, and Series MAT117 .docx
Special Topics on Functions, Sequences, and Series MAT117 .docx
MARRY7
 
Chapter 2 Mathematical Language and Symbols.pdf
Chapter 2 Mathematical Language and Symbols.pdfChapter 2 Mathematical Language and Symbols.pdf
Chapter 2 Mathematical Language and Symbols.pdf
RaRaRamirez
 
Mathematics power point presenttation on the topic
Mathematics power point presenttation on the topicMathematics power point presenttation on the topic
Mathematics power point presenttation on the topic
Meghansh Gautam
 
Reportgroup4 111016004939-phpapp01
Reportgroup4 111016004939-phpapp01Reportgroup4 111016004939-phpapp01
Reportgroup4 111016004939-phpapp01
Nurhidayah Mahmud
 
E212d9a797dbms chapter3 b.sc2
E212d9a797dbms chapter3 b.sc2E212d9a797dbms chapter3 b.sc2
E212d9a797dbms chapter3 b.sc2
Mukund Trivedi
 

Similar to Expression tree (20)

Python.pptx
Python.pptxPython.pptx
Python.pptx
 
I am kind of confused about quantifiers. I am not sure how to transl.pdf
I am kind of confused about quantifiers. I am not sure how to transl.pdfI am kind of confused about quantifiers. I am not sure how to transl.pdf
I am kind of confused about quantifiers. I am not sure how to transl.pdf
 
Relational Data Model Introduction
Relational Data Model IntroductionRelational Data Model Introduction
Relational Data Model Introduction
 
Iipm chapter 1
Iipm chapter 1Iipm chapter 1
Iipm chapter 1
 
LANGUAGE-OF-RELATIONS-AND-FUNCTIONS.pptx
LANGUAGE-OF-RELATIONS-AND-FUNCTIONS.pptxLANGUAGE-OF-RELATIONS-AND-FUNCTIONS.pptx
LANGUAGE-OF-RELATIONS-AND-FUNCTIONS.pptx
 
java_lect_03-2.ppt
java_lect_03-2.pptjava_lect_03-2.ppt
java_lect_03-2.ppt
 
Special Topics on Functions, Sequences, and Series MAT117 .docx
 Special Topics on Functions, Sequences, and Series MAT117 .docx Special Topics on Functions, Sequences, and Series MAT117 .docx
Special Topics on Functions, Sequences, and Series MAT117 .docx
 
Relations & Functions.pptx
Relations & Functions.pptxRelations & Functions.pptx
Relations & Functions.pptx
 
ERD.pptx
ERD.pptxERD.pptx
ERD.pptx
 
Entity Relationship Diagram
Entity Relationship DiagramEntity Relationship Diagram
Entity Relationship Diagram
 
Unit-II DBMS presentation for students.pdf
Unit-II DBMS presentation for students.pdfUnit-II DBMS presentation for students.pdf
Unit-II DBMS presentation for students.pdf
 
Programming in Scala - Lecture Three
Programming in Scala - Lecture ThreeProgramming in Scala - Lecture Three
Programming in Scala - Lecture Three
 
Chapter 2 Mathematical Language and Symbols.pdf
Chapter 2 Mathematical Language and Symbols.pdfChapter 2 Mathematical Language and Symbols.pdf
Chapter 2 Mathematical Language and Symbols.pdf
 
Grade 7 Mathematics Week 4 2nd Quarter
Grade 7 Mathematics Week 4 2nd QuarterGrade 7 Mathematics Week 4 2nd Quarter
Grade 7 Mathematics Week 4 2nd Quarter
 
Mathematics power point presenttation on the topic
Mathematics power point presenttation on the topicMathematics power point presenttation on the topic
Mathematics power point presenttation on the topic
 
Reportgroup4 111016004939-phpapp01
Reportgroup4 111016004939-phpapp01Reportgroup4 111016004939-phpapp01
Reportgroup4 111016004939-phpapp01
 
Unary and binary set operations
Unary and binary set operationsUnary and binary set operations
Unary and binary set operations
 
presentation.pdf bnksjqwjkwlsjoilhsnwososh
presentation.pdf bnksjqwjkwlsjoilhsnwososhpresentation.pdf bnksjqwjkwlsjoilhsnwososh
presentation.pdf bnksjqwjkwlsjoilhsnwososh
 
MAT1033.4.5.ppt
MAT1033.4.5.pptMAT1033.4.5.ppt
MAT1033.4.5.ppt
 
E212d9a797dbms chapter3 b.sc2
E212d9a797dbms chapter3 b.sc2E212d9a797dbms chapter3 b.sc2
E212d9a797dbms chapter3 b.sc2
 

More from NagajothiN1 (11)

Apache Oozie
Apache OozieApache Oozie
Apache Oozie
 
mobile jammer
mobile jammermobile jammer
mobile jammer
 
Version control libraries
Version control librariesVersion control libraries
Version control libraries
 
Designing data marts
Designing data marts Designing data marts
Designing data marts
 
8 queen problem
8 queen problem8 queen problem
8 queen problem
 
8 queen problem
8 queen problem8 queen problem
8 queen problem
 
Over view of data structures
Over view of data structuresOver view of data structures
Over view of data structures
 
Over view of data structures
Over view of data structuresOver view of data structures
Over view of data structures
 
Over view of data structures
Over view of data structuresOver view of data structures
Over view of data structures
 
Over view of data structures
Over view of data structuresOver view of data structures
Over view of data structures
 
Over view of data structures
Over view of data structuresOver view of data structures
Over view of data structures
 

Recently uploaded

QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
httgc7rh9c
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 

Recently uploaded (20)

QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Our Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdfOur Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdf
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
PANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxPANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptx
 

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