Search in AI
- 35Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What is the key difference between a reflex agent and a planning agent?
35 questions
- 1
What is the key difference between a reflex agent and a planning agent?
Model answer
A reflex agent chooses actions based on its current percept and memory without considering future consequences, while a planning agent considers the future consequences of its actions using a model of the world and a goal test.
Explanation
Reflex agents react to the present; planning agents evaluate hypothetical futures to decide actions.
- 2
Can a reflex agent ever be rational? Explain.
Model answer
Yes, a reflex agent can be rational in specific circumstances if its fixed action mapping happens to produce the optimal action. However, in general it cannot be rational because it cannot adapt to different situations or consider future consequences.
Explanation
Rationality requires maximizing expected utility; reflex agents lack the flexibility to do so across all scenarios.
- 3
What must a planning agent have to make decisions based on future consequences?
Model answer
A planning agent must have a model of how the world evolves in response to its actions and a goal test to determine whether a future state satisfies its objective.
Explanation
Without a model, the agent cannot predict outcomes; without a goal test, it cannot evaluate which futures are desirable.
- 4
What are the four components of a search problem?
Model answer
The four components are a set of states, a successor function (with actions and costs), a start state, and a goal test.
Explanation
These define the possible configurations, transitions, initial situation, and success condition.
- 5
Define the successor function in a search problem. What does it take as input and what does it output?
Model answer
The successor function takes a state and an action as input, and outputs the next state and the cost of that action.
Explanation
It describes the transition model and the cost associated with each action.
- 6
What is a solution to a search problem?
Model answer
A solution is a sequence of actions (a plan) that transforms the start state into a goal state.
Explanation
The plan must be feasible according to the successor function and end in a state satisfying the goal test.
- 7
What is abstraction in the context of search problems? Why is it necessary?
Model answer
Abstraction is the simplification of the real world into a model that includes only details relevant to planning. It is necessary because the real world state space is too large or complex to handle directly.
Explanation
By ignoring irrelevant details, we create a feasible search problem that still captures essential aspects for reaching the goal.
- 8
In the Romania pathfinding example, what is the state, start state, and goal test?
Model answer
The state is the current city (e.g., Arad). The start state is Arad. The goal test is whether the current city is Bucharest.
Explanation
The successor function corresponds to roads with costs connecting cities.
- 9
Compare world state and search state. Give an example where they differ.
Model answer
World state includes every detail of the environment, while search state keeps only details needed for planning. For pathfinding, the search state is just the agent's location, but the world state includes positions of all objects, etc.
Explanation
The search state is a projection of the world state onto relevant dimensions.
- 10
For the eat-all-dots problem, what are the components of the search state?
Model answer
The search state includes the agent's position and a Boolean array indicating the presence of dots at each location.
Explanation
The agent's position determines possible moves, and the dot status determines whether the goal (all dots eaten) is achieved.
- 11
How does adding the constraint 'keep ghosts perma-scared' change the search state? What additional information must be tracked?
Model answer
The search state must also track how many big dots remain and how much time is left for the ghosts to be scared.
Explanation
The agent must plan to eat power pellets before their effect wears off, requiring temporal information.
- 12
For the Pac-Man world state example with 120 agent positions, 30 food pellets, 12 ghost positions each, and 4 facing directions, what is the total number of world states? Express as a product.
Model answer
120×230×122×4
Explanation
Each dot can be present or not (2 options per dot, so 230), ghost positions are independent (12 each, assuming they can overlap), and agent facing direction (4).
- 13
What is the difference between a state space graph and a search tree?
Model answer
In a state space graph, each state appears only once and nodes represent states. In a search tree, each node represents a path from the start to a state, so the same state can appear multiple times (different paths). The search tree can be infinite due to cycles.
Explanation
The state space graph is a mathematical representation; the search tree is the expansion used by search algorithms.
- 14
Why can the search tree be infinite even if the state space graph is finite?
Model answer
Because cycles in the state space graph lead to repeated states in the search tree, generating infinitely many paths if the algorithm does not check for repeats.
Explanation
Without loop detection, the tree keeps expanding through cycles.
- 15
In the search tree, what does each node correspond to?
Model answer
Each node corresponds to a path (sequence of actions) from the start state to a particular state.
Explanation
The node stores not just the state but also the path taken to reach it.
- 16
Describe the general tree search algorithm. What are the steps?
Model answer
The algorithm takes a problem and a strategy. It initializes the fringe with the start state. Then it loops: if the fringe is empty, fail; else pick a leaf node from the fringe according to the strategy, if it is a goal, return solution; else expand the node, adding its children to the fringe.
Explanation
The strategy determines which node to expand next.
- 17
What is the fringe in tree search?
Model answer
The fringe is the set of partial plans (paths) that are under consideration for expansion. It consists of the leaves of the search tree that have not yet been expanded.
Explanation
The fringe represents all possible continuations that the algorithm could explore next.
- 18
How does depth-first search (DFS) choose which node to expand from the fringe?
Model answer
DFS uses a last-in, first-out (LIFO) stack; it expands the node that was most recently added to the fringe.
Explanation
It goes deep along one path before backtracking.
- 19
Under what conditions is DFS complete? When is it incomplete?
Model answer
DFS is complete if the state space is finite and there is a depth limit (or if loop checking is used) to prevent infinite paths. It is incomplete if the state space is infinite or if there are cycles that cause infinite descent without reaching a goal.
Explanation
Without a bound, DFS may keep exploring an infinite branch.
- 20
Is DFS optimal? Why or why not?
Model answer
No, DFS is not optimal because it may find a solution that is not the cheapest or shortest; it returns the first solution it finds, which depends on the expansion order.
Explanation
DFS does not consider cost or depth; it just picks the deepest node first.
- 21
What are the time and space complexities of DFS? Define b and m.
Model answer
Time complexity is O(bm), where b is the branching factor and m is the maximum depth of the tree. Space complexity is O(bm), because at worst the fringe stores b nodes at each level along the current path.
Explanation
In the worst case, DFS may explore the entire tree, but its memory usage is linear in depth.
- 22
How can depth-first search be modified to be complete in finite state spaces?
Model answer
By adding loop checking (also called visited set or cycle detection), where the algorithm does not expand a node if it has already been explored on the current path or globally.
Explanation
This prevents infinite loops and ensures that every state is visited at most once, making DFS complete for finite state spaces.
- 23
How does breadth-first search (BFS) select which node to expand?
Model answer
BFS uses a first-in, first-out (FIFO) queue; it expands the node that has been waiting the longest on the fringe.
Explanation
It explores nodes level by level.
- 24
Is BFS complete? Explain.
Model answer
Yes, BFS is complete because it expands all nodes at a given depth before moving to deeper depths, so it will eventually reach any goal at finite depth.
Explanation
Even if the state space is infinite, if a goal exists at finite depth, BFS will find it.
- 25
Under what condition is BFS optimal? Why?
Model answer
BFS is optimal if all action costs are identical (e.g., unit costs). It finds the shallowest goal, which in that case is also the least-cost path.
Explanation
BFS does not consider differing action costs; if costs are uniform, shallowest equals cheapest.
- 26
What are the time and space complexities of BFS? Define b and s.
Model answer
Time complexity is O(bs), where s is the depth of the shallowest solution. Space complexity is O(bs), as the fringe can hold up to bs nodes at the deepest level explored.
Explanation
BFS stores all nodes at the current depth level before moving deeper, leading to exponential memory.
- 27
When would you prefer DFS over BFS?
Model answer
When memory is limited, because DFS uses O(bm) memory while BFS uses O(bs), which can be much larger. DFS can find a solution quickly if it gets lucky, but in the worst case it may be slower.
Explanation
BFS's memory demand can be prohibitive for large branching factors.
- 28
What is iterative deepening search? How does it combine the benefits of DFS and BFS?
Model answer
Iterative deepening runs DFS with an increasing depth limit. It has the space advantage of DFS (O(bd)) and the time advantage of BFS (it is optimal and complete for unit costs, and guarantees finding the shallowest solution). The total time is only slightly more than BFS.
Explanation
The overhead of re-exploring shallow levels is constant-factor because most nodes are at the deepest level.
- 29
Why is the time overhead of iterative deepening relatively small compared to BFS?
Model answer
Because most nodes in a search tree are at the deepest level. The total number of node expansions is approximately b−1bbd, which is only a constant factor more than BFS's bd.
Explanation
Re-expanding shallow levels adds negligible overhead relative to the exponential size of the deepest level.
- 30
How does uniform cost search (UCS) decide which node to expand?
Model answer
UCS uses a priority queue ordered by the total path cost from the start. It expands the node with the lowest cumulative cost so far.
Explanation
It always explores the cheapest partial path first.
- 31
Under what conditions is UCS complete?
Model answer
UCS is complete if there is a minimum positive cost per action (i.e., all costs are bounded below by ϵ>0). This ensures that the cost of paths increases without bound, so the algorithm will eventually reach any goal.
Explanation
Without a positive minimum cost, the algorithm could keep exploring infinitely cheap paths forever.
- 32
Is UCS optimal? Why?
Model answer
Yes, UCS is optimal because it expands nodes in order of increasing path cost, and it stops when the goal is the cheapest node on the fringe. Only when the goal is popped from the priority queue can we guarantee no cheaper path exists.
Explanation
All nodes with cost less than the optimal solution are expanded before the goal is returned.
- 33
What is the worst-case time complexity of UCS? Define relevant parameters.
Model answer
O(bC∗/ϵ), where C∗ is the optimal path cost and ϵ is the minimum action cost. The effective depth is at most C∗/ϵ.
Explanation
The number of steps in the optimal path is bounded by C∗/ϵ, leading to exponential blowup in the worst case.
- 34
How much memory does UCS require in the worst case?
Model answer
UCS requires O(bC∗/ϵ) memory, as the fringe may hold all nodes with cost less than the optimal solution cost, which can be exponential in the effective depth.
Explanation
Similar to BFS, UCS stores all nodes within the current cost contour.
- 35
What is the main disadvantage of UCS compared to informed search?
Model answer
UCS explores equally in all directions with no information about the goal's location, which can be inefficient if the goal is far away. Informed search uses heuristics to focus expansion toward the goal.
Explanation
UCS treats all directions equally, expanding many irrelevant states.

Ask anything
We've read this whole study set, so questions about it get the best answers.