Traversal
Traversal is the systematic process of visiting elements or nodes in a data structure according to a specified order or rule.
Grokking Data Structures
Array traversal is the process of visiting the elements of an array, typically to inspect or process their values.
- How it is used
- Applies an operation to every array element and supports scans that find values such as a maximum.
- How deep it goes
- Works through a Python callback loop and a maximum-index scan, including empty-array handling and initial-value choice.
- Examples
- Uses printing array elements and scanning die-face counters for the most frequent roll.
- What you can do after
- Build it from scratch with a Python loop and callback, or adapt the scan to track a largest value and its index.
Algorithms Every Programmer Should Know
Traversal is the process of visiting the elements of a data structure in sequence to locate or process them.
- How it is used
- Uses traversal to locate data in linked lists and search nodes in trees.
- How deep it goes
- Defines linked-list scans from the head, notes their O(N) cost, and contrasts tree searches by depth and layer.
- Examples
- Traces scanning from a linked-list head and searching for node 8 from tree root 5 with DFS or BFS.
- What you can do after
- Apply traversal by scanning linked-list nodes from the head or searching tree nodes with BFS or DFS.
Read how Algorithms Every Programmer Should Know explains traversal →
Retrieval Augmented Generation, The Foundational Ideas
Graph traversal is the process of visiting nodes by following edges through a graph from one or more starting points.
- How it is used
- Supports retrieval by narrowing candidate context through hierarchical descent or graph reachability instead of relying on one similarity search.
- How deep it goes
- Explains traversal definitions, layer-by-layer scoring, pruning, entry-level control, and graph retrieval roles without detailing full graph construction.
- Examples
- Uses Finance-versus-HR branch pruning, leaf-specific entry levels, and entity paths such as a marketing director connected to a safety failure.
- What you can do after
- Apply it via layer-by-layer top-k descent, controlled entry levels, or entity-centered graph paths when broad similarity retrieval misfires.
Read how Retrieval Augmented Generation, The Foundational Ideas explains traversal →
AI-Powered Search
Graph traversal is the process of visiting nodes and relationships in a graph according to a specified path or sequence of steps.
- How it is used
- Uses search indexes to connect terms, queries, categories, and documents for semantic search and query disambiguation.
- How deep it goes
- Explains bidirectional index lookups, chained levels, scored edges, and configurable traversal inputs without detailing the scoring implementation.
- Examples
- Demonstrates skill-to-job paths, disconnected nodes, and server, driver, and chef queries separated by category.
- What you can do after
- Apply it via SKG traversal to discover related terms, chain graph levels, or disambiguate queries by category.
Optimization Algorithms: AI techniques for design, planning, and control problems
A graph-search technique that explores a tree or graph by visiting nodes according to a specified rule.
- How it is used
- Uses rule-based exploration to discover paths through trees and graphs in routing, puzzles, mazes, and relationship networks.
- How deep it goes
- Defines traversal and distinguishes BFS, DFS, DLS, IDS, and bidirectional search, but stops short of route-length optimization.
- Examples
- Demonstrates traversal through mazes, n-puzzles, family trees, social graphs, and origin-to-destination routing.
- What you can do after
- Apply BFS, DFS, DLS, IDS, or bidirectional search to find paths through simple, well-defined graph problems.
Also covered in
- Secrets of the JavaScript Ninja, Second Edition
- Graph Algorithms for Data Science
- Functional Programming in Scala, Second Edition
- AI-Powered Developer: Build software with ChatGPT and Copilot
- Grokking Algorithms, Second Edition
- Context EngineeringIn early access (MEAP)
- Clojure: The Essential Reference
- Knowledge Graphs and LLMs in Action
- Digital Twins in Action
- Advanced Algorithms and Data Structures
- Build an AI Agent (From Scratch)
- Software Design for Python Programmers
What to know first
- graph databaseA graph database is a database system that represents data as entities and their relationships, typically using nodes and edges, and supports queries over that structure.
- language modelA language model is a computational model that represents patterns in linguistic sequences to assign probabilities, predict, generate, or evaluate language.
- similarity searchSimilarity search is a retrieval technique that finds or ranks items by their similarity to a query, often by comparing feature or vector representations under a similarity or distance measure.
- nodeA node is a discrete element of a graph, tree, linked structure, network, or computing system that can represent an entity, state, or component and may connect to other elements.
Related concepts
- breadth-first searchincludes · Breadth-first search is a graph or tree traversal algorithm that explores nodes in nondecreasing order of their distance from a starting node.
- collapsed treealternative to · Collapsed tree is a retrieval strategy that flattens hierarchical nodes into one index and retrieves across all abstraction levels in a single search.
- recursive traversalincludes · Recursive traversal visits the elements of a hierarchical or graph-like structure by recursively processing each element’s related child elements.
- depth-first searchincludes · Depth-first search is a traversal strategy that follows a branch as far as possible before backtracking to explore alternatives.
- postorder traversalincludes · A postorder traversal visits each node after visiting its children or subtrees.
Questions about traversal
What is traversal?
Traversal is the systematic process of visiting elements or nodes in a data structure according to a specified order or rule.
Which Manning books explain traversal?
Grokking Data Structures, Algorithms Every Programmer Should Know, Retrieval Augmented Generation, The Foundational Ideas, AI-Powered Search and Optimization Algorithms: AI techniques for design, planning, and control problems.
What should I know before learning traversal?
Manning books that teach traversal usually introduce graph database, language model, similarity search and node first.
What is the difference between traversal and collapsed tree?
Traversal is the systematic process of visiting elements or nodes in a data structure according to a specified order or rule. Collapsed tree is a retrieval strategy that flattens hierarchical nodes into one index and retrieves across all abstraction levels in a single search.
What kinds of traversal are there?
Kinds of traversal include breadth-first search, recursive traversal, depth-first search, postorder traversal and inorder traversal.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.




