Inorder traversal
Appearance
In Computer science, Inorder traversal is used in Data structures, and specifically, Trees and Binary Trees.
Programs that utilize tree strucutres need to process nodes in a tree (represented as circles in below diagram). Nodes contain information about an object. For now, let's assume each node contains a letter. The arrows indicate a link between nodes.
InOrder Traversal is a type of Tree Traversal algorithm. Inorder refers to when the root is processed inbetween to its two subtrees.
Steps to Inorder Traversal
Given a non-empty tree,
- Process the nodes in the left subtree with a recursive call
- Process the root
- Process the nodes in the right subtree with a recursive call
Given a binary tree PY:
The order would go D,B,G,E,A,C,F
Compare: Pre-order traversal, post-order traversal