Artificial Intelligence · Unit 3
Search Algorithms and Techniques
Exam-focused notes for Search Algorithms and Techniques (Artificial Intelligence, BIT252): what the TU syllabus asks and how it has actually been tested, with 10 solved past questions from this unit.
Search Algorithms and Techniques in short
Search is how an AI program finds a sequence of actions from a start state to a goal. This chapter covers blind search, heuristic search, search in AND-OR graphs, and search in games.
What this unit covers
- Depth first search
- Breadth first search
- Depth limited search
- Iterative deepening search
- Hill climbing search
- Greedy best first search
- A* search algorithm
- AO* search for multiple goals
- Alpha beta pruning in game trees
- Search algorithm evaluation factors
Iterative deepening search
2082 · 5 marks
How iterative deepening search is used to find goal in state space? Illustrate using example. [5]
Depth limited search
2080 · 10 marks
How do Depth Limited Search solve the problem of Depth First Search and discuss about its limitations? Illustrate the concept of AO* search in multiplication of any 3 matrices.[10]
Hill climbing search
2080 · 5 marks
Discuss about Hill climbing search with its limitations. [5]
2079 · 10 marks
Justify that AI can't exist without searching? Solve the following 8 puzzle problem using Hill climbing search algorithm.
Initial State: $$\begin{array}{|c|c|c|}\hline 1 & 2 & 4 \ \hline 5 & & 7 \ \hline 3 & 6 & 8 \ \hline\end{array}$$
Goal State: $$\begin{array}{|c|c|c|}\hline 1 & 4 & 7 \ \hline 2 & 5 & 8 \ \hline 3 & 6 & \ \hline\end{array}$$
[10]
Show solved answerHide answer
AI Cannot Exist Without Searching + Hill Climbing on 8-Puzzle
Part 1: Justify That AI Cannot Exist Without Searching (4 marks)
Search is the process of systematically exploring a state space to find a sequence of actions leading from an initial state to a goal state.
Justification:
-
Problem formulation is universal in AI. Almost every AI problem is formulated as an initial state, a set of actions, a transition model, a goal test, and a path cost. Solving it means finding a path, which is search.
-
Intelligence requires choosing among alternatives. An intelligent agent faces many possible states and actions. Selecting the right action toward a goal inherently requires exploring alternatives, that is, searching.
-
Without search only two options remain, both non-intelligent:
- Acting randomly (not rational), or
- Using a fixed hardcoded response (not general, not adaptive).
-
All major AI subfields rely on search:
| AI Task | Role of Search |
|---|---|
| Problem solving | Explore action sequences to reach goal |
| Game playing | Search move/counter-move trees (Minimax) |
| Path finding, robotics | Find route from start to destination |
| Planning | Search for a valid plan |
| Machine learning | Gradient descent searches a hypothesis/parameter space |
| Theorem proving | Search inference chains |
Conclusion: Whether uninformed (BFS, DFS), informed (A*, Hill Climbing), or adversarial (Minimax), every intelligent behavior reduces to navigating a problem space. Hence AI cannot exist without searching.
Part 2: 8-Puzzle Using Hill Climbing (6 marks)
Given Data
Initial State
1 2 4
5 _ 7
3 6 8
Goal State
1 4 7
2 5 8
3 6 _
Heuristic: number of misplaced tiles $h(n)$ (blank excluded). Hill Climbing moves to a neighbor with lower $h$.
Goal Positions (row, col)
| Tile | Goal | Tile | Goal | Tile | Goal |
|---|---|---|---|---|---|
| 1 | (0,0) | 4 | (0,1) | 7 | (0,2) |
| 2 | (1,0) | 5 | (1,1) | 8 | (1,2) |
| 3 | (2,0) | 6 | (2,1) | blank | (2,2) |
Step 0: Evaluate Initial State
1 2 4
5 _ 7
3 6 8
| Tile | Current | Goal | Misplaced? |
|---|---|---|---|
| 1 | (0,0) | (0,0) | No |
| 2 | (0,1) | (1,0) | Yes |
| 4 | (0,2) | (0,1) | Yes |
| 5 | (1,0) | (1,1) | Yes |
| 7 | (1,2) | (0,2) | Yes |
| 3 | (2,0) | (2,0) | No |
| 6 | (2,1) | (2,1) | No |
| 8 | (2,2) | (1,2) | Yes |
$$h(\text{initial}) = 5$$
Step 1: Generate Successors (blank at (1,1))
UP (swap blank with 2):
1 _ 4
5 2 7
3 6 8
Misplaced: 4, 5, 2, 7, 8 → $h = 5$
DOWN (swap blank with 6):
1 2 4
5 6 7
3 _ 8
Misplaced: 2, 4, 5, 6, 7, 8 → $h = 6$
LEFT (swap blank with 5):
1 2 4
_ 5 7
3 6 8
Misplaced: 2, 4, 7, 8 → $h = 4$ ✓ (5 now correct at (1,1))
RIGHT (swap blank with 7):
1 2 4
5 7 _
3 6 8
Misplaced: 2, 4, 5, 7, 8 → $h = 5$
Best successor: LEFT, with $h = 4 < 5$. Move there.
Step 2: Current State $h = 4$ (blank at (1,0))
1 2 4
_ 5 7
3 6 8
Successors:
UP (swap with 1):
_ 2 4
1 5 7
3 6 8
Misplaced: 1, 2, 4, 7, 8 → $h = 5$
DOWN (swap with 3):
1 2 4
3 5 7
_ 6 8
Misplaced: 2, 4, 3, 7, 8 → $h = 5$
RIGHT (swap with 5, returns toward previous):
1 2 4
5 _ 7
3 6 8
$h = 5$ (the initial state)
Best successor $h = 5$, but current $h = 4$.
Since no neighbor improves on $h = 4$ (all are $\geq 5$), Hill Climbing halts here.
Result
Hill Climbing gets stuck at:
1 2 4
_ 5 7
3 6 8 h = 4
This is a local minimum (also a plateau/ridge situation): every move increases $h$. Therefore plain (steepest-ascent) Hill Climbing fails to reach the goal for this puzzle.
Why it fails: Hill Climbing is greedy and has no backtracking. When it reaches a state whose neighbors are all worse, it stops even though the global goal ($h=0$) is not reached. To escape, one would use techniques such as:
- Random-restart Hill Climbing
- Simulated Annealing
- Stochastic / sideways moves
- Or a complete search like A* with Manhattan distance.
Final answer: Using number-of-misplaced-tiles heuristic, Hill Climbing improves from $h=5$ to $h=4$ then gets stuck at a local minimum and cannot reach the goal state.
Alpha beta pruning in game trees
2079 · 5 marks
What is the purpose of alpha beta pruning? Explain. [5]
Show solved answerHide answer
Alpha-Beta Pruning
Purpose
The purpose of alpha-beta pruning is to reduce the number of nodes evaluated in the minimax search tree without affecting the final result. It allows the minimax algorithm to search deeper in the same amount of time by eliminating (pruning) branches that cannot possibly influence the final decision.
Note: Reference notes were not available for this topic; the following is based on standard AI curriculum material consistent with TU BSc CSIT syllabus.
Background
The Minimax algorithm explores the entire game tree to find the optimal move, but this is computationally expensive. For a game tree with branching factor b and depth d, minimax evaluates O(b^d) nodes.
Alpha-beta pruning reduces this to approximately O(b^(d/2)) in the best case, effectively doubling the searchable depth.
Key Concepts
| Parameter | Role |
|---|---|
| Alpha (α) | The best (highest) value that the MAX player can guarantee so far. Initialized to -∞ |
| Beta (β) | The best (lowest) value that the MIN player can guarantee so far. Initialized to +∞ |
How It Works
- The algorithm performs a standard depth-first minimax search.
- At each node, it maintains the α and β values.
- Pruning occurs when:
- At a MIN node: if the current value becomes ≤ α, prune remaining children (Alpha cutoff).
- At a MAX node: if the current value becomes ≥ β, prune remaining children (Beta cutoff).
Pruning Conditions
At MAX node: if value >= β → PRUNE (Beta cutoff)
At MIN node: if value <= α → PRUNE (Alpha cutoff)
Example
Consider the following minimax tree:
MAX
/ \
MIN MIN
/ \ / \
3 5 2 9
- MAX evaluates left MIN node → gets min(3,5) = 3, so α = 3
- MAX evaluates right MIN node → sees value 2
- Since 2 < α (3), the right subtree value cannot exceed 3
- The remaining child (9) is pruned -- no need to evaluate it
- Final answer: MAX chooses 3
Advantages
- Efficiency: Reduces time complexity from O(b^d) to O(b^(d/2)).
- Same result: Always produces the same optimal move as full minimax.
- Deeper search: Allows AI to look further ahead within the same time limit.
- Practical use: Widely used in game-playing AI (chess, checkers, tic-tac-toe).
Summary
Alpha-beta pruning is an optimization technique for the minimax algorithm that prunes branches which cannot affect the outcome, using two boundary values α and β. It makes game-tree search significantly faster while guaranteeing the same optimal decision as the full minimax search.
Search algorithm evaluation factors
2080.2 · 10 marks
How do you evaluate any searching algorithm? What are constraint satisfaction problems? Differentiate between Greedy Best First Search and A* search.[10]
Depth first search
2080.2 · 5 marks
Distinguish between Depth First Search and Breadth First Search. [5]
AO* search for multiple goals
0 · 10 marks
Illustrate the concept of AO* search with an example. Which search will work on multiple goals environment? What are the four evaluation factors of searching algorithm?[10]
A* search algorithm
0 · 5 marks
Define agent. Describe the heuristic function of A* search? [5]
Make Unit 3 stick
Practice BIT252 with flashcards & quizzes