questions and answers
Section 1: Search Algorithms (Q1-30)
Question 1
When is the A* search algorithm guaranteed to find the optimal path?
A) Always
B) When the heuristic is admissible
C) When the heuristic is consistent (monotonic)
D) Both B and C
Answer: D
Rationale: A* is guaranteed to be optimal if the heuristic is admissible (never
overestimates the true cost to reach the goal) [citation:1]. Consistency (or
monotonicity) is a stricter property than admissibility; if a heuristic is consistent,
A* is optimal and also ensures graph-search efficiency without needing to revisit
nodes. Therefore, both conditions ensure optimality.
Question 2
,You are using Depth-First Search (DFS) on a tree with depth d and branching
factor b. What is the worst-case space complexity?
A) O(b*d)
B) O(b+m) where m is the max length
C) O(bd)
D) O(d)
Answer: D
Rationale: Unlike Breadth-First Search (BFS) which stores the entire frontier
(O(b^d)), DFS only maintains a single path from the root to the current node plus
sibling nodes waiting to be explored. Its space complexity is linear in the depth of
the tree d.
Question 3
If the heuristic h(n) is admissible, which of the following must be true for A*?
A) f(n) is non-decreasing along any path
B) The first solution found is always optimal
C) The algorithm runs faster than Dijkstra's
D) It will expand fewer nodes than BFS
,Answer: B
Rationale: The primary guarantee of an admissible heuristic is that A* will return
the optimal path when it finds a solution. While consistency guarantees efficiency
(no re-expansions), admissibility alone ensures optimality even if nodes need to
be re-opened.
Question 4
Simulated Annealing is primarily used to avoid getting stuck in:
A) A plateau
B) A local maximum/minimum
C) An infinite loop
D) The goal state
Answer: B
Rationale: Simulated annealing uses a temperature parameter and a cooling
schedule. At high temperatures, it allows "uphill" moves (accepting worse states)
to escape local optima. As the temperature cools, it behaves more like hill
climbing to settle into a global optimum.
Question 5
, What is the primary difference between Uniform Cost Search (UCS) and A*
search?
A) UCS uses a heuristic; A* does not
B) A* uses a heuristic; UCS does not
C) UCS expands nodes based on path cost, while A* expands based on cost +
heuristic
D) A* is optimal only with negative edge weights
Answer: B
Rationale: Uniform Cost Search expands nodes based solely on the cumulative
path cost g(n). A* expands based on the sum f(n) = g(n) + h(n), where h(n) is the
estimated cost to the goal. The heuristic directs A* toward the goal, potentially
exploring fewer nodes than UCS.
Question 6
In the context of genetic algorithms, what is "crossover"?
A) Randomly changing a gene
B) Selecting the fittest individual
C) Combining parts of two parent solutions
D) Discarding the worst solutions