## Table of Contents

# X-order

X-orders are typically used to describe the specific order in which the nodes are visited in a tree traversal algorithm.

**Inorder traversal**: visits the left subtree, root, and right subtree.**Preorder traversal**: visits the root, left subtree, and right subtree.**Postorder traversal**: visits the left subtree, right subtree, and root.

Each traversal algorithm has its own use cases, and the choice of algorithm depends on the specific problem being solved.

For example, inorder traversal is often used to visit all the nodes of a binary search tree in ascending order, while postorder traversal is used to delete all nodes of a binary tree.

# X-fix

X-fix, also called x-fix notation is a way of writing mathematical expressions.

**Infix notation**is the standard notation used in most programming languages, and it is the notation that people are most familiar with. In infix notation, the operator is placed__between__the operands.**Prefix notation**, also called*Polish notation*, is a way of writing mathematical expressions in which the operator comes__before__the operands.**Postfix notation**, also called*reverse Polish notation*, is a way of writing mathematical expressions in which the operator comes__after__the operands.

In summary, each of these notation has its own characteristics and use cases. The differences between the three notations are the position of the operator in relation to the operands.

## Simple Example

Take a look at the following expression tree:

This tree could be represented in every fixes, pay attention to the position of the operator:

- Infix notation: $a + b$
- Prefix notation: $+\ a\ b$
- Postfix notation: $a\ b\ +$

## Complex Example

The expression below comes from the last post:

$\left( \frac{x^{2}}{y-xz} \right)+\left\{ \left( 2\frac{yz}{x+y} \right) / \left( x+y^{2} \right) \right\}$And we’ve made the expression tree for it:

If we try to form the infix notation, we’ll get

That’s why in infix notation we have to use brackets to indicate the order of operations and to group together sub-expressions that should be evaluated as one. This ensure that the expressions are evaluated in the intended order and make it more readable.

- Infix notation

- Prefix notation

- Postfix notation

While the prefix and postfix looked like they’re the inverse of each other, they actually have different orders. Be careful not to easily get trapped on this slight similarity.