CS 188
Spring 2024 Regular Discussion 1
1 Towers of Hanoi
The Towers of Hanoi is a famous problem for studying recursion in computer science and recurrence equations
in discrete mathematics. We start with N discs of varying sizes on a peg (stacked in order according to size),
and two empty pegs. We are allowed to move a disc from one peg to another, but we are never allowed to move
a larger disc on top of a smaller disc. The goal is to move all the discs to the rightmost peg (see the figure above).
In this problem, we will formulate the Towers of Hanoi as a search problem.
(a) Propose a state representation for the problem.
(b) What is the size of the state space?
(c) What is the start state?
(d) From a given state, what actions are legal?
1
(e) What is the goal test?
2 Search Algorithms in Action
For each of the following graph search strategies, work out the order in which states are expanded, as well
as the path returned by graph search. In all cases, assume ties resolve in such a way that states with earlier
alphabetical order are expanded first. Remember that in graph search, a state is expanded only once.
a) Depth-first search.
b) Breadth-first search.
c) Uniform cost search.