# Traversal of a Binary-Tree

In this blog post we will investigate four key algorithms used to read through the content of a binary tree:

• Depth-First Algorithms:
• Pre-Order Traversal
• In-Order Traversal
• Post-Order Traversal

#### Binary Tree?

A Binary Tree is a data structure used in some algorithms to store data. In a binary tree each node can have up to two children.

A Breadth-first traversal consists of accessing each node, one level after the ohter. On each layer the nodes are accessed as they appear, from left to right.

#### Depth-First Traversal Algorithms

There are three depth-first traversal agorithms which are all based on a recursive approach.

Pre-Order Traversal Algorithm:

In-Order Traversal Algorithm:

Post-Order Traversal Algorithm:

#### Binary Tree #1

 Breadth First: (view solution) Depth-first Pre-order Traversal: (view solution) Depth-first In-order Traversal: (view solution) Depth-first Post-order Traversal: (view solution)

#### Binary Tree #2

 Breadth First: (view solution) Depth-first Pre-order Traversal: (view solution) Depth-first In-order Traversal: (view solution) Depth-first Post-order Traversal: (view solution)

#### Binary Tree #3

 Breadth First: (view solution) Depth-first Pre-order Traversal: (view solution) Depth-first In-order Traversal: (view solution) Depth-first Post-order Traversal: (view solution)

#### Binary Tree #4

 Breadth First: (view solution) Depth-first Pre-order Traversal: (view solution) Depth-first In-order Traversal: (view solution) Depth-first Post-order Traversal: (view solution)
Tagged with: