liveBook · Manning

Visited

As explained in Classic Computer Science Problems in Swift: Essential techniques for practicing programmers

visited is the set of search states that have already been explored.

visited is the set of search states already explored. A search marks a state when it discovers it, preventing cycles and repeated work while the frontier continues toward a goal. section 2.2

Maze search

In a grid maze, MazeLocation values identify positions. When DFS reaches a location, visited prevents it from following links back into already searched locations and becoming trapped in a loop. Parent pointers still preserve the successful route for reconstruction. section 2.2

How Classic Computer Science Problems in Swift: Essential techniques for practicing programmers covers it

How deep it goes
Defines the set and shows insertion and membership checks in generic Swift DFS and BFS, without analyzing storage or complexity.
Examples
Uses MazeLocation states, a generated grid maze, DFS, BFS, and reconstructed paths as concrete examples.
What it assumes
Assumes hashable state values, goal tests, successor functions, and a frontier abstraction such as Stack or Queue.
What you can do after
Apply it in Swift search functions to avoid repeated exploration and reconstruct a route through maze states.
How it connects
Connects search states with frontiers, depth-first search, breadth-first search, successor functions, and parent pointers.

This explainer was generated by Manning's knowledge graph from the text of Classic Computer Science Problems in Swift: Essential techniques for practicing programmers. The section links point to the parts of the book it draws on.