Written by the Fiveable Content Team โข Last updated September 2025
Verified for the 2026 exam
Verified for the 2026 examโขWritten by the Fiveable Content Team โข Last updated September 2025
Definition
Traversals refer to the process of visiting and accessing each element in a data structure, such as a tree or graph, exactly once.
Related terms
Depth-First Search (DFS): An algorithm that explores as far as possible along each branch before backtracking. It is often used for traversing trees or graphs.
Breadth-First Search (BFS): An algorithm that explores all the vertices of a graph at the same level before moving on to the next level. It is commonly used for finding shortest paths.
In-order traversal: A type of traversal specifically used for binary trees where nodes are visited in ascending order based on their values.