Prev: L16, Next: L18

Zoom: Link, Piazza: Link, Google Form: Link.

Wisc ID for in-class quiz: (if your wisc email is "test@wisc.edu", please enter "test")
Token: (will be given during the lectures)



# Warning: this is a draft and will be updated one day before the lecture.


Slide:



# Search Problems

📗 Search problems solve for a sequence of optimal actions to minimize the total cost of these actions.
📗 Reinforcement learning is similar but the cost is unknown so the agent has the learn the costs (usually in the form of reward) while finding the optimal actions.
➩ Board games.
➩ Robotic control.
➩ Autonomous vehicle control.
➩ Economic models.
➩ Large language models.
📗 The total number of possible action sequences is large, so efficient algorithms are needed to search only the relevant ones.
➩ Tic Tac Toe: \(10^{3}\).
➩ Checkers: \(10^{20}\).
➩ Chess: \(10^{50}\).
➩ Go: \(10^{170}\).



# State Space Graph

📗 A search problem is defined by a state space graph (search graph): Wikipedia.
➩ \(V\) is the set of nodes (or vertices) representing the states (outcome from a sequence of actions).
➩ \(E\) is the set of edges (or arcs) representing the possible actions at each state.
➩ \(c\) is the cost (or weights) associated with each edge, assumed to be positive.
📗 The search graph is usually in the form of a tree.
➩ At the beginning of a search, only the initial state is expanded.
➩ The list of states that can be reached from some state \(s\) by performing some action is called successors of \(s\).
➩ Expanding a state means generating the list of successors and adding them to the search tree.
➩ The leafs of the search tree is called the frontier (or the fringe).
➩ The search is over when a goal state is expanded. The path from the initial state to the goal state is called a solution to the search problem.
➩ The solution is optimal if it has the smallest cost.
📗 A search strategy is the order in which the states are expanded.
In-class Discussion
📗 [1 points] people with one flashlight (torch) want to go across a river. The bridge can hold two people at a time, and they must cross with the flashlight. The time it takes for each person to cross the river:
A B C D

What is the minimum total time required for everyone to cross the river?
📗 Answer: .




# Search Performance

📗 A search strategy is complete if it finds at least one solution.
📗 A search strategy is optimal if it finds the optimal solution.
📗 The time complexity of a search strategy is the worst case maximum number of states expanded.
📗 The space complexity of a search strategy is the worst case maximum number of states stored in the frontier at a single time.
📗 Time and space complexities are usually expressed as a function of depth and branching factor.
➩ The depth of the goal state is denoted by \(d\).
➩ The maximum depth of a search tree is denoted by \(D\).
➩ The maximum number of actions associated with a state is called the branching factor, denoted by \(b\).
In-class Discussion
📗 Search for a page containing an image. Describe how you find the image.
📗 Start here: Link.



# Breadth First Search

📗 BFS (Breadth First Search) uses Queue for the frontier: remove from the front, add to the back: Wikipedia.
📗 BFS is complete.
📗 BFS is optimal when the cost of every action is 1.
📗 Time complexity is \(T = 1 + b + b^{2} + ... + b^{d}\).
➩ This count includes the root and the goal.
📗 Space complexity is \(S = b^{d+1}\).
📗 Bidirectional search does BFS from the initial and goal states at the same time and stops when they meet.
In-class Quiz (Past Exam Question) ID:
📗 [4 points] Suppose the states are integers between and . The initial state is , and the goal state is . The successors of a state \(i\) are \(2 i\) and \(2 i + 1\), if exist. How many states are expanded using a ? Include both the initial and goal states.
📗 Note: use the convention used in the lectures, push the states with larger index into the stack first (i.e. expand the states with the smaller index first).


📗 Answer: .




# Depth First Search

📗 DFS (Depth First Search) uses Stack for the frontier: remove from the front, add to the front: Wikipedia.
📗 DFS is incomplete if \(D = \infty\).
📗 DFS is not optimal.
📗 Time complexity is \(T = 1 + b^{D-d+1} + ... + b^{D-1} + b^{D}\).
➩ This count includes the root and the goal.
📗 Space complexity is \(S = \left(b - 1\right) D + 1\).
In-class Quiz (Past Exam Question) ID:
📗 [4 points] Suppose the states are integers between and . The initial state is , and the goal state is . The successors of a state \(i\) are \(2 i\) and \(2 i + 1\), if exist. How many states are expanded using a ? Include both the initial and goal states.
📗 Note: use the convention used in the lectures, push the states with larger index into the stack first (i.e. expand the states with the smaller index first).


📗 Answer: .




# Iterative Deepening Search

📗 IDS (Iterative Deepening Search) performs multiple DFS with increasing depth limits: Wikipedia.
📗 IDS (Iterative Deepening Search) performs multiple DFS with increasing depth limits: Wikipedia.
➩ DFS and stops if path length is larger than \(1\).
➩ DFS and stops if path length is larger than \(2\).
➩ ...
➩ DFS and stops if path length is larger than \(d\).
📗 IDS is complete.
📗 IDS is optimal when the cost of all actions are 1.
📗 Time complexity is \(T = \left(d + 1\right) + d b + \left(d - 1\right) b^{2} + ... + 3 b^{d-2} + 2 b^{d-1} + 1 b^{d}\).
➩ This count includes the root and the goal, and the first DFS step is only on the root.
📗 Space complexity is \(S = \left(b - 1\right) d + 1\).
In-class Discussion
📗 What is a good search strategy for the water jugs game (note: there are cycles, so the search tree can be a search graph if the search strategy does not keep track of the visited states): Link.




# Questions?

📗 If you have questions, please use (i) Zoom chat, (ii) Piazza: Link, (iii) Office hours and discussion sessions. Please do NOT use Canvas mail and use email only to the course instructor (not TAs) for grading issues.
Additional In-class Discussion
📗 Sometimes a question not in the notes will be asked during the lecture, you can submit your answer here:

Notes (not visible to other students):


Submit your answer to see other students answers (click the submit button to refresh): 

Additional In-class Quiz
📗 Sometimes a question not in the notes will be asked during the lecture, you can submit your answer here:
A.
B.
C.
D.
E.
Notes (not visible to other students):


Submit your answer to see other students answers (click the submit button to refresh): 






# In-class Quiz Instructions

📗 To get full points on the in-class quizzes for a lecture:
➩ Submit relevant answers to the questions discussed during the lecture: incorrect answers are okay.
➩ Some questions require [notes] to earn the point.
➩ Some questions require special ID (given during the lecture) to earn the point.
➩ Do not submit answers to questions that are not discussed during the lectures. Each such submission will result in a deduction of one point.
➩ Submissions after the lecture, before the midterm (first 14 lectures) and the final exam (last 14 lectures), are accepted. After the exams, no in-class quiz submissions will be accepted.
➩ The grade on Canvas Assignment Q17 is computed as number of points divided by the number of questions asked (out of 1) and updated on Canvas every weekend.
📗 If there are any issues with submission on the website, please use this Google form: Link.
📗 Bonus point opportunities during a few lectures (added to in-class quiz above 20 points).
📗 Notes and code adapted from the course taught by Professors Jerry Zhu, Blerina Gkotse, Yudong Chen, Yingyu Liang, Charles Dyer. Some content are generated using Copilot .

Prev: L16, Next: L18





Last Updated: June 26, 2026 at 3:06 AM