Now that we understand trees, graphs, and state spaces, we can finally explore how AI systems actually search through these structures to find solutions. In this section, weโll look at uninformed searchโsometimes called blind searchโwhich is the most basic approach to searching through a state space.
An uninformed search strategy uses only the information that comes with the problem itself: where you start, what moves you can make, and how to recognize when youโve reached the goal. The algorithm has no additional guidance about which paths are more promising or how close a state might be to the goal.
Think of it like exploring a maze with no map, no compass, and no sense of direction. You can only move step by step and explore systematically, but you have no "intuition" about which direction to head. You might try every path until you eventually find the exitโor get hopelessly lost.
Because they lack guidance, uninformed search methods are generally slower than informed methods and take more time to find solutions. However, they are guaranteed to find a solution (if one exists) and, in some cases, guaranteed to find the best one. This makes them valuable tools when:
Uninformed search is like trying to find a book in a huge library without using the catalog. You have to walk down every aisle, check every shelf, and examine every book until you happen to find the one youโre looking for. It will work eventually, but itโs not very efficient!
Breadth-first search (BFS) is one of the simplest search strategies. It explores all nodes at the current level before moving to the next level. In other words, BFS examines the shallowest (closest to the start) unexamined node first.
Imagine youโre at the entrance of a maze. BFS is like exploring every path one step at a time: you take one step down every possible corridor, then two steps down every possible corridor, then three steps, and so on. You never go deeper down any single path until youโve checked everything at your current distance from the start.
Yesโit will always find a solution if one exists
Optimal
Yesโbut only if all moves have the same cost
Time
Can be very slowโit may need to explore many nodes
Space
Can use a lot of memoryโit stores many nodes at once
Best for: Problems where the shortest path is the goal, the number of possible moves from each state is small, memory is not a concern, and all moves cost the same.
Weakness: BFS can use a huge amount of memory. For a problem where each state has 10 possible moves, BFS might need to store billions of states in memory before finding a solution!
Depth-first search (DFS) takes the opposite approach. DFS explores as far as possible along each branch before turning back. It expands the deepest (farthest from the start) unexpanded node first.
Imagine youโre exploring a maze by walking down one corridor as far as it goes. When you hit a dead end, you turn back to the last fork and try the next corridor. You keep doing this until you find the exit.
Depth-limited search (DLS) is a version of DFS that avoids the infinite-loop problem by setting a maximum depth limit. The algorithm stops exploring any branch once it reaches this limit.
It works exactly like DFS, but with a rule: "Donโt go deeper than depth L." If you reach depth L without finding the goal, simply stop exploring that branch and turn back.
Youโre building a foundation โ Understanding uninformed search is a prerequisite for understanding informed search, just as learning basic arithmetic comes before algebra.
Think of it like searching for a lost item in a building: If you want to check every room on each floor before moving up, use BFS. If you want to search the same room on every floor (101, 201, 301) before moving to the next, use DFS.