AI engineering glossary · Data structures algorithms
What is tree traversal?
Tree traversal (also called inorder traversal, preorder, postorder): A systematic way of visiting every node of a tree exactly once. Common orders are preorder (node, left, right), inorder (left, node, right), postorder (left, right, node) and level order (row by row). Inorder on a search tree yields keys in sorted order.
Tree traversal: an example
Inorder traversal of a binary search tree holding 30, 10, 50 and 20 prints 10, 20, 30, 50.
Related terms
More Data structures algorithms terms
- Trie
- Two pointers
- Union-find
- Weighted graph
- Worst-case analysis
- A* search
- Abstract data type
- Adjacency list
Where you learn it
Tree traversal is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.