Published Aug 10, 2022
Contribute to Docs
Inorder traversal is a depth-first search algorithm for a binary search tree that first traverses the left subtree, then the root, then traverses the right subtree. This provides the nodes of the binary search tree in increasing order. To get nodes in decreasing order, inorder traversal can be done in reverse.
The inorder algorithm can be described as follows:
Function Inorder(tree) return Inorder(left-subtree) + root + Inorder(right-subtree)
For the following binary search tree:
Inorder traversal provides the nodes in the following order:
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn More on Codecademy
Computer ScienceLooking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
Includes 6 Courses
With Professional Certification