Overview

3 Blind Search Algorithms

This chapter introduces blind (uninformed) search within deterministic algorithms and grounds it in graph fundamentals. It describes graphs as collections of vertices and edges that can be directed or undirected, multigraphs with parallel edges, acyclic structures, hypergraphs that connect many nodes at once, and weighted networks where edge costs matter. The text emphasizes how these representations model real systems—social networks, telecommunications, and especially road networks—and shows how common tooling can construct and explore such graphs. With this foundation, the chapter motivates blind search as a practical, repeatable approach for exploring state spaces and finding paths in well-defined problems such as sliding-tile puzzles, family trees, social connections, mazes, and city routing tasks.

Two traversal methods anchor the discussion: Breadth-First Search (BFS) and Depth-First Search (DFS). BFS expands level by level using a FIFO queue, guarantees finding a solution if one exists in a finite graph, and is well suited to shallow goals but can be memory intensive (time and space grow rapidly with branching factor and depth). DFS descends along a path using a LIFO stack, backtracks at dead ends, and is memory efficient but can wander deep without finding nearby solutions; a depth limit can mitigate this. Through examples like the 8‑puzzle and grid-based path planning, the chapter contrasts their behaviors and introduces Big‑O analysis to reason about scalability, highlighting trade-offs between time, space, and problem structure when selecting a traversal strategy.

For optimal routing on weighted graphs, the chapter presents Dijkstra’s algorithm, Uniform-Cost Search (UCS), and Bidirectional Dijkstra. Dijkstra computes shortest paths with non‑negative edge costs via a priority queue; UCS is a practical variant that grows the frontier incrementally and reduces overhead, behaving like BFS when all edges have equal cost; bidirectional search runs forward from the source and backward from the goal to cut the search space dramatically. A campus routing case study shows that these methods produce identical optimal routes while differing in time and memory usage. The chapter also notes practical details for real maps—choosing the lightest among parallel edges and ignoring self‑loops to avoid path reconstruction issues. It concludes that BFS/DFS can find feasible (not necessarily optimal) routes quickly, whereas Dijkstra/UCS/Bidirectional Dijkstra yield provably shortest paths, and previews how informed search will leverage domain knowledge to improve efficiency further.

Undirected graph.
A directed graph.
Example of a multi-graph. Notice the three parallel edges connecting nodes 0 and 1, as well as the two edges connecting nodes 3 and 4.
An acyclic graph. There is no path that cycles back to any starting node.
An example of a hypergraph. Hyperedges can connect more than two nodes, such as hyperedge 0, which links nodes A, B, and G.
Example of a weighted graph.
St. George Campus - University of Toronto
Road network around St. George Campus - University of Toronto
Visualizing points of interest using folium markers
Graph Search Methods.
Using BFS to solve 8-puzzle problem
Step-by-step BFS solution using Python. BFS searches for a solution but does not consider optimality.
Solving path planning problem using BFS – Step 1
Solving path planning problem using BFS – Step 2
Solving path planning problem using BFS – Step 3
Solving path planning problem using BFS – Step 4
Solving path planning problem using BFS – Step 5
Solving path planning problem using BFS – Final route
Examples of big O notations
Using DFS to solve the 8-puzzle problem
Solving path planning problem using DFS – Step 1
Solving path planning problem using DFS – Step 2
Solving path planning problem using DFS – Step 3
Solving path planning problem using DFS – Step 4
Solving path planning problem using DFS
Dijkstra’s algorithm and its variants
Finding shortest path using Dijkstra’s algorithm – Step 0
Finding shortest path using Dijkstra’s algorithm – Step 1
Finding shortest path using Dijkstra’s algorithm – Step 2
Finding shortest path using Dijkstra’s algorithm – Step 3
Finding shortest path using Dijkstra’s algorithm – Step 4
Finding shortest path using Dijkstra’s algorithm – Step 5
Bidirectional Dijkstra
Dijkstra vs Bidirectional Dijkstra. Blue represents the forward exploration, while red shows the backward exploration.
BFS routing using Python. BFS searches each layer first, before moving to the next. This works best for graphs that are not very broad and has a solution located near the root node.
DFS routing using Python. DFS searches as deep as possible in the graph before “backtracking”. This works best when the graph is not very deep, and solutions are located further away from the root node.
Dijkstra’s, UCS, and Bidirectional Dijkstra’s routing. All three of these algorithms will produce the same solution (optimal routing), but handle memory usage and node exploration differently.
Parallel edges may be problematic as finding the shortest path depends on which parallel edge was selected during graph exploration.
Self-loops may disrupt the chain of “parent-child nodes”, which prevents retracing the route after a solution has been found.

Summary

  • Conventional graph search algorithms (blind and informed search algorithms) are deterministic search algorithms that explore a graph either for general discovery or for explicit search.
  • Graph is a non-linear data structure consisting of vertices and edges.
  • Blind/uninformed search is a search approach where no information about the search space is used.
  • Breadth-first Search (BFS) is a graph traversal algorithm that examines all the nodes in a search tree on one level before considering any of the nodes on the next level.
  • Depth-first Search (DFS) is a graph traversal algorithm that first explores nodes going through one adjacent of the root, then next adjacent until it finds a solution or until it reaches a dead-end.
  • Depth-limited Search (DLS) is a constrained DFS with a predetermined depth limit to prevent exploring paths that are too long in a search tree with infinite depth.
  • Iterative Deepening Search (IDS) or Iterative Deepening Depth First Search (IDDFS) combines DFS's space efficiency and BFS's fast search by incrementing the depth limit until the goal is reached.
  • Dijkstra's algorithm solves the single-source shortest path problem for a weighted graph with non-negative edge costs.
  • Uniform-cost Search (UCS) is a variant of Dijkstra's algorithm that uses the lowest cumulative cost to find a path from the source to the destination. It is equivalent to the BFS algorithm if the path cost of all edges is the same.
  • Bidirectional Search (BS) is a combination of forward and backward search. It searches forward from the start and backward from the goal simultaneously.
  • Selecting a search algorithm involves determining the target balance between time complexity, space complexity, and prior knowledge about the search space, among other factors.
  • As you progress to Chapter 4, you will start to learn about informed search algorithms where additional information or heuristic rules are used during the search.

FAQ

What are blind (uninformed) search algorithms and how do they differ from informed search?Blind search algorithms do not use domain knowledge about the search space (for example, estimated distance to the goal). They explore states uniformly and typically stop when the first feasible solution is found, which may be non-optimal. Optimality can be achieved only by exhaustively enumerating all feasible solutions. In contrast, informed methods use problem-specific information (heuristics) to guide the search. Examples of blind methods in this chapter include BFS, DFS, DLS, IDS, Dijkstra, UCS, and bidirectional search.
What kinds of graphs are introduced in this chapter?The chapter covers undirected and directed graphs, multigraphs (parallel edges), acyclic graphs (including DAGs), and hypergraphs (hyperedges connect many nodes). It also distinguishes weighted vs unweighted graphs, where edge weights can represent distance, time, cost, capacity, or signal strength. Practical libraries include networkx for general graph work, hypernetx for hypergraphs, and osmnx for road networks extracted from OpenStreetMap.
How does Breadth-first Search (BFS) work and when should I use it?BFS explores a graph level by level from a start node using a FIFO queue, visiting all current neighbors before moving deeper. It finds a solution if one exists and, when all edges have equal cost, returns a shallowest-path solution. Time and space can grow exponentially with depth (≈ O(b^d)); for graphs G=(V,E) its run time is O(|V|+|E|). Use BFS when the solution is near the root and the branching factor is manageable.
How does Depth-first Search (DFS) work and when is it preferable?DFS explores as deep as possible along a path using a LIFO stack, backtracking when it hits a dead end. It has time complexity ≈ O(b^d) but uses much less memory, O(b·d), than BFS. DFS can wander indefinitely down very deep branches; depth-limited search and iterative deepening mitigate this risk. It is preferable when memory is tight, the graph is very wide, paths are not excessively deep, or solutions lie deeper in the tree.
What is the difference between BFS and DFS in practice?BFS is typically more time-efficient at finding shallow solutions but is memory-intensive; DFS is more memory-efficient but may take longer and return convoluted paths when goals are near the root. BFS uses a queue and expands nodes level-wise; DFS uses a stack and expands deepest nodes first with backtracking. BFS is a good fit when branching factor is moderate and goals are shallow; DFS suits cases with limited memory and deeper solutions.
What does Dijkstra’s algorithm solve and what are its key requirements?Dijkstra’s algorithm computes shortest paths with non‑negative edge costs, producing optimal routes (single-source to others or to a target). With an efficient priority queue, the complexity is O(|E| + |V| log |V|). In this chapter’s implementation, it stops once the target is reached (faster on large road networks). For multigraphs and self-loops common in map data, the approach discards longer parallel edges and ignores self-loops to preserve correctness.
How is Uniform-Cost Search (UCS) related to Dijkstra, and when is it advantageous?UCS is a variant of Dijkstra that expands nodes in order of lowest cumulative cost using a priority queue, but it grows the frontier lazily instead of initializing all nodes. It is especially useful on large or implicit graphs where generating the entire graph upfront is impractical. When all edge costs are equal, UCS behaves like BFS and expands nodes level by level. It produces optimal paths under non‑negative edge costs.
What is bidirectional Dijkstra and why can it be faster?Bidirectional Dijkstra runs two searches simultaneously: forward from the source and backward from the goal, meeting somewhere in between. This roughly halves the effective depth, reducing the search space from O(b^d) to about O(b^(d/2)), a substantial gain. Alternating expansions and detecting the overlap yields the same optimal path with fewer explored nodes and less memory in many cases.
How are real-world road networks modeled and searched in this chapter?The chapter uses osmnx to fetch street graphs from OpenStreetMap and folium for map visualization. Nodes represent intersections or points of interest; directed, weighted edges represent streets with attributes like length or speed. BFS/DFS find feasible routes but not necessarily shortest; Dijkstra, UCS, and bidirectional Dijkstra produce the same optimal path while differing in time and space use. Care is taken to handle parallel edges and self-loops correctly in map-derived graphs.
What are the main scalability and complexity takeaways for blind search?Blind search can grow rapidly with branching factor and depth; BFS in particular has exponential space needs (≈ O(b^d)). DFS uses linear space in depth but can waste time exploring deep, unproductive branches. Shortest-path methods (Dijkstra, UCS, bidirectional) are optimal with non‑negative weights and scale better on large weighted graphs, especially when implemented with priority queues and bidirectional expansion. Big‑O analysis helps choose an approach that balances time and memory for the problem size.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Optimization Algorithms ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Optimization Algorithms ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Optimization Algorithms ebook for free