Binary Expression Trees

A binary expression tree is a specific kind of a binary tree used to represent expressions. Two common types of expressions that a binary expression tree can represent are algebraic expressions and boolean expressions. These trees can represent expressions that contain both unary and binary operators.

Algebric Expression Trees


An algebric expression such as (3 * 7) + 9 consists of:

  • Operands such as 3, 7, 9 or x, y, z,
  • Binary Operators such as +, – , *, /, DIV, MOD, ^
  • Unary Operators such as –

Algebric expressions can be represented using a binary expression tree where:

  • Each node is an operator,
  • Each leaf is an operand.
algebric-expression-tree-1 Algebric Expression: (view solution)
algebric-expression-tree-2 Algebric Expression: (view solution)
algebric-expression-tree-3 Algebric Expression: (view solution)
expression-tree-question Algebric Expression:
expression-tree-question Algebric Expression:
expression-tree-question Algebric Expression:

Boolean Expression Trees


An Boolean expression such as (A OR B) AND C consists of:

  • Operands such as A, B, C,
  • Binary Operators such as AND, OR, XOR
  • Unary Operators such as NOT

Boolean expressions can be represented using a binary expression tree where:

  • Each node is an operator,
  • Each leaf is an operand.
Boolean-expression-tree-1 Boolean Expression: (view solution)
Boolean-expression-tree-2 Boolean Expression: (view solution)
expression-tree-question Boolean Expression:
expression-tree-question Boolean Expression:

Did you like this challenge?

Click on a star to rate it!

Average rating 4 / 5. Vote count: 9

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!

Tagged with: