2 Search fundamentals

 

This chapter covers

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

What are planning and searching?

When we think about what makes us intelligent, the ability to plan before carrying out actions is a prominent attribute. Before embarking on a trip to a different country, before starting a new project, before writing functions in code, planning happens. Planning happens at different levels of detail in different contexts to strive for the best possible outcome when carrying out the tasks involved in accomplishing goals (figure 2.1).

Figure 2.1 Example of how plans change in projects
A screenshot of a cell phone Description automatically generated

Plans rarely work out perfectly in the way we envision at the start of an endeavor. We live in a world in which environments are constantly changing, so it is impossible to account for all the variables and unknowns along the way. Regardless of the plan we started with, we almost always deviate due to changes in the problem space. We need to (again) make a new plan from our current point going forward, if after we take more steps, unexpected events occur that require another iteration of planning to meet the goals. As a result, the final plan that is carried out is usually different from the original one.

Cost of computation: The reason for smart algorithms

Problems applicable to searching algorithms

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: The concrete structures used to represent search solutions

Uninformed search: Looking blindly for solutions

Breadth-first search: Looking wide before looking deep

Depth-first search: Looking deep before looking wide

Use cases for uninformed search algorithms

Optional: More about graph categories

Optional: More ways to represent graphs

Incidence matrix

Adjacency list

Summary of search fundamentals