# Prefix Traversal to form Expression from Expression Tree

<< Previous - Expression Tree Examples

Postfix Expression from Expression Tree >>

Expression Tree is used to represent expressions. Let us look at how to form prefix expressions from an expression tree

## Steps to Write Prefix Expressions from Expression Tree for a*b+c

## Writing Prefix Expression From Expression Tree

Let us how to generate the prefix expression from the tree. A prefix expression is generated from the tree as follows:

__Consider the root__.**+**Prefix expression created so far = +

__Next consider the left subtree__.**a * b**- For
**a * b**, Consider the root of subtree*****.Prefix expression created so far = + *

- For
**a * b**, Consider the left subtree**a**. Left subtree has only one node**a**, Hence, first write the same.Prefix expression created so far = + * a

- For
**a * b**, Consider the right subtree**b**. Right subtree**b**is just a node.Prefix expression created so far = + * a b

- For
__Consider the right subtree__. Since the right subtree is just a simple node, there is no more subtrees to be checked**c**Prefix expression created so far = + * a b c

How to write Infix Expression >>

How to write Postfix Expression >>

<< Previous - Expression Tree Examples