Search Algorithms Lecture
- 17Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
In the city block problem described in the lecture, which search algorithms can be used to find the optimal path from City 1 to City n and back to City 1, given non-negative edge costs cij that are not necessarily uniform?
In the city block problem described in the lecture, which search algorithms can be used to find the optimal path from City 1 to City n and back to City 1, given non-negative edge costs cij that are not necessarily uniform?
17 questions
- 1
In the city block problem described in the lecture, which search algorithms can be used to find the optimal path from City 1 to City n and back to City 1, given non-negative edge costs cij that are not necessarily uniform?
- A
Breadth-first search and uniform cost search only
- B
Depth-first search and dynamic programming only
- C
Depth-first search and breadth-first search only
- D
Dynamic programming and uniform cost search only
Correct answer
DDynamic programming and uniform cost search only
Explanation
Depth-first search requires zero costs, and breadth-first search requires uniform costs. Since cij≥0 but not necessarily uniform, only dynamic programming (which allows cycles when state includes direction) and uniform cost search (which handles non-negative costs and cycles) are applicable.
- A
- 2
Why can't depth-first search be used in the city block problem with non-zero edge costs?
- A
Depth-first search requires all edge costs to be zero.
- B
Depth-first search cannot handle cycles.
- C
Depth-first search only works for tree-structured state spaces.
- D
Depth-first search requires uniform edge costs.
Correct answer
ADepth-first search requires all edge costs to be zero.
Explanation
Depth-first search assumes that reaching any goal state is sufficient, which works only if all edges have zero cost. Non-zero costs make the path cost matter, so DFS does not guarantee optimality.
- A
- 3
What is a state in the context of search problems?
- A
The set of all actions available at a given point.
- B
The current location of the agent in the environment.
- C
A summary of all past actions sufficient to choose future actions optimally.
- D
The cost incurred so far from the start state.
Correct answer
CA summary of all past actions sufficient to choose future actions optimally.
Explanation
A state is defined as a summary of all past actions that are sufficient for optimal future decision-making. It may include more than just location, e.g., direction in the back-and-forth city problem.
- A
- 4
In the back-and-forth city problem (City 1 to City n forward, then back to City 1 backward), how can dynamic programming be applied despite the apparent cycle?
- A
By ignoring the return trip and solving only the forward path.
- B
By setting all edge costs to zero and using uniform cost search.
- C
By extending the state to include both city and direction of travel.
- D
By using depth-first search with memoization to break cycles.
Correct answer
CBy extending the state to include both city and direction of travel.
Explanation
Including direction in the state (e.g., City 4 going forward vs. City 4 going backward) breaks the cycle, making the state space acyclic. Dynamic programming can then be applied.
- A
- 5
In uniform cost search, what data structure is used to manage the frontier?
- A
A stack
- B
A queue
- C
A priority queue
- D
A hash set
Correct answer
CA priority queue
Explanation
Uniform cost search uses a priority queue (often implemented as a min-heap) to efficiently pop the state with the smallest past cost from the frontier.
- A
- 6
What is the runtime complexity of uniform cost search when the number of states explored is n?
- A
O(2n)
- B
O(n2)
- C
O(nlogn)
- D
O(n)
Correct answer
CO(nlogn)
Explanation
The runtime is O(nlogn) due to priority queue operations (pop and update) for each state, assuming a sparse graph. In worst-case dense graphs, it may be O(n2logn).
- A
- 7
The correctness theorem for uniform cost search states that when a state s is popped from the frontier, its priority (past cost) is:
- A
The cost of the first path found to s.
- B
An upper bound on the optimal cost to s.
- C
The minimum possible cost to reach s from the start.
- D
The maximum possible cost to reach s from the start.
Correct answer
CThe minimum possible cost to reach s from the start.
Explanation
The theorem proves that when s is popped, the past cost is the optimal (minimum) cost to reach s. The proof uses the explored set and the fact that any alternative path must have higher or equal cost.
- A
- 8
Which of the following is a key difference between dynamic programming and uniform cost search?
- A
Dynamic programming cannot handle negative costs, while uniform cost search can.
- B
Dynamic programming has O(nlogn) runtime; uniform cost search is O(n).
- C
Uniform cost search handles cycles; dynamic programming requires a DAG.
- D
Uniform cost search requires the cost to be the same for all actions.
Correct answer
CUniform cost search handles cycles; dynamic programming requires a DAG.
Explanation
Uniform cost search can handle cycles (by revisiting nodes with better costs), while dynamic programming typically requires a DAG or a state space made acyclic by state augmentation. Dynamic programming runs in O(n) and handles arbitrary costs (including negative) as long as no negative cycles.
- A
- 9
When the costs of actions are unknown, but we have data on optimal paths, what is the inverse problem called?
- A
Cost relaxation
- B
Reinforcement learning
- C
Structured perceptron learning
- D
Heuristic search
Correct answer
CStructured perceptron learning
Explanation
The lecture describes learning costs from optimal paths as an inverse problem, and presents the structured perceptron algorithm for this purpose. It is not reinforcement learning (which involves reward and exploration) but a supervised learning approach.
- A
- 10
In the structured perceptron algorithm for learning action costs, how are weights updated after each example?
- A
Randomly perturb weights and keep the change if prediction improves.
- B
Set weights equal to the count of each action in the true path.
- C
Decrease weights for actions in the true path and increase weights for actions in the predicted path.
- D
Increase weights for actions in both the true and predicted paths.
Correct answer
CDecrease weights for actions in the true path and increase weights for actions in the predicted path.
Explanation
The algorithm subtracts 1 from the weight of each action in the true path (to make it cheaper) and adds 1 to each action in the predicted path (to make it more expensive), encouraging the model to favor the true path.
- A
- 11
What is the purpose of the heuristic function h(s) in A* search?
- A
To store the past cost from the start to state s.
- B
To replace the actual edge costs with a simpler function.
- C
To ensure the search explores all states uniformly.
- D
To estimate the future cost from state s to the goal.
Correct answer
DTo estimate the future cost from state s to the goal.
Explanation
The heuristic h(s) provides an estimate of the optimal cost from s to the goal (future cost). A* uses g(s)+h(s) to order exploration, where g(s) is the past cost.
- A
- 12
How does A* search modify the edge costs to incorporate a heuristic?
- A
It multiplies each edge cost by the heuristic value of the current state.
- B
It subtracts the heuristic of the current state from the edge cost.
- C
It replaces the edge cost with the heuristic difference: c′(s,a)=c(s,a)+h(s′)−h(s).
- D
It adds the heuristic value of the successor to the edge cost.
Correct answer
CIt replaces the edge cost with the heuristic difference: c′(s,a)=c(s,a)+h(s′)−h(s).
Explanation
A* transforms the cost of each edge to c′(s,a)=c(s,a)+h(s′)−h(s), where s′ is the successor. This encourages moving toward states with lower heuristic values.
- A
- 13
A heuristic h is consistent if it satisfies which condition?
- A
h(s)≤h(s′) for all s′ reachable from s.
- B
h(s)≥0 for all states and h(sgoal)=0.
- C
c(s,a)+h(s′)≥h(s) for all transitions and h(sgoal)=0.
- D
h(s)=0 for all states.
Correct answer
Cc(s,a)+h(s′)≥h(s) for all transitions and h(sgoal)=0.
Explanation
Consistency requires c(s,a)+h(s′)≥h(s) (triangle inequality) and h(sgoal)=0. This ensures the transformed costs c′(s,a) are non-negative and that h is admissible.
- A
- 14
If a heuristic is consistent, what additional property does it automatically satisfy?
- A
Dominance: h(s)≥0 only.
- B
Monotonicity: h(s)≥h(s′) for all successors s′.
- C
Optimality: h(s)=FutureCost(s) for all s.
- D
Admissibility: h(s)≤FutureCost(s) for all s.
Correct answer
DAdmissibility: h(s)≤FutureCost(s) for all s.
Explanation
Consistency implies admissibility. An admissible heuristic never overestimates the true future cost. The proof uses induction: for the goal it holds, and consistency ensures the condition propagates backward.
- A
- 15
What is the benefit of using a larger (but still admissible) heuristic in A* search?
- A
It allows negative edge costs in the transformed problem.
- B
It guarantees finding the goal with zero exploration.
- C
It reduces the number of states explored, making the search more efficient.
- D
It increases the search space to ensure optimality.
Correct answer
CIt reduces the number of states explored, making the search more efficient.
Explanation
A larger admissible heuristic provides a better estimate of future cost, focusing the search more toward the goal and reducing the number of states with g(s)+h(s) less than the optimal cost. This improves efficiency.
- A
- 16
In the 8-puzzle, a common heuristic is the Manhattan distance sum. What relaxation does this heuristic correspond to?
- A
Removing the goal state constraints.
- B
Allowing tiles to move through each other (overlap).
- C
Allowing any tile to move to any empty space instantly.
- D
Allowing tiles to move diagonally.
Correct answer
BAllowing tiles to move through each other (overlap).
Explanation
Manhattan distance sum relaxes the constraint that tiles cannot occupy the same square. By assuming tiles can overlap, each tile can move independently to its goal, giving a lower bound on actual moves.
- A
- 17
What is the main idea behind deriving heuristics through relaxation?
- A
Remove some constraints from the original problem and solve the easier problem to get an estimate.
- B
Assume all edge costs are zero and use breadth-first search.
- C
Add extra constraints to make the problem more realistic.
- D
Use machine learning to train a heuristic from data.
Correct answer
ARemove some constraints from the original problem and solve the easier problem to get an estimate.
Explanation
Relaxation simplifies the problem by removing constraints, making it solvable (often with closed-form or efficient algorithms). The optimal cost of the relaxed problem is a heuristic (lower bound) for the original problem.
- A

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