chapter two

2 Search fundamentals

 

In this chapter

  • Gaining the intuition of planning and searching
  • Identifying problems suited to be solved using search algorithms
  • Representing problem spaces in a way suitable for processing by search algorithms
  • Understanding and designing fundamental search algorithms to solve problems

What are planning and searching?

The ability to plan before acting is a hallmark of intelligence. Before going on a trip to a different country, before starting a new project, before writing functions in code, we plan. Planning happens at different levels of detail to strive for the best possible outcome when carrying out the tasks required to accomplish goals (figure 2.1).

Figure 2.1 Example of how plans change in projects

Plans rarely work out exactly the way we envision them at the start. We live in a world where things are constantly changing, so it is impossible to account for all the variables and unknowns along the way. Regardless of the plan we start with, we almost always deviate from it. We need to (again) make a new plan from our current point going forward as unexpected events occur. As a result, the final plan that is carried out is usually quite different from the original one.

Cost of computation: The reason for smart algorithms

Problems that search algorithms can solve

Representing state: Creating a framework to represent problem spaces and solutions

Graphs: Representing search problems and solutions

Representing a graph as a concrete data structure

Trees: Concrete structures used to represent search solutions

Uninformed search: Looking blindly for solutions

BFS: Looking wide before looking deep

Steps of the BFS algorithm

Incidence matrix