TUT 2
Question 1
DFS:
Bucharest -> Urzicenl -> Vasiul -> Iasi -> Neamt
Bucharest -> Urzicenl -> Hirsova -> Eforie
Bucharest -> Pitesti -> Rimnicu Vilcea -> Sibiu -> Oradea -> Zerind -> Arad -> Timisoara
BFS:
Bucharest -> Urzicenl
Bucharest -> Pitesti
Bucharest -> Glurgiu
Bucharest -> Fagaras
Bucharest -> Urzicenl -> Vasiul
Bucharest -> Urzicenl -> Hirsova
Bucharest -> Pitesti -> Rimnicu Vilcea
Bucharest -> Pitesti -> Craiova
Bucharest -> Fagaras -> Sibiu
Bucharest -> Urzicenl -> Vasiul -> Iasi
Bucharest -> Urzicenl -> Hirsova -> Eforie
Bucharest -> Pitesti -> Rimnicu Vilcea -> Sibiu
Bucharest -> Pitesti -> Rimnicu Vilcea -> Craiova
Bucharest -> Pitesti -> Craiova -> Rimnicu Vilcea
Bucharest -> Pitesti -> Craiova -> Dobreta
Bucharest -> Fagaras -> Sibiu -> Rimnicu Vilcea
Bucharest -> Fagaras -> Sibiu -> Oradea
Bucharest -> Fagaras -> Sibiu -> Arad
Bucharest -> Urzicenl -> Vasiul -> Iasi -> Neamt
Bucharest -> Pitesti -> Rimnicu Vilcea -> Sibiu -> Oradea
Bucharest -> Pitesti -> Rimnicu Vilcea -> Sibiu -> Fagaras
Bucharest -> Pitesti -> Rimnicu Vilcea -> Sibiu -> Arad
Bucharest -> Pitesti -> Rimnicu Vilcea -> Craiova -> Dobreta
Bucharest -> Pitesti -> Craiova -> Rimnicu Vilcea -> Sibiu
Bucharest -> Pitesti -> Craiova -> Dobreta -> Mehadia
Bucharest -> Fagaras -> Sibiu -> Rimnicu Vilcea -> Pitesti
Bucharest -> Fagaras -> Sibiu -> Rimnicu Vilcea -> Craiova
Bucharest -> Fagaras -> Sibiu -> Oradea -> Zerind
Bucharest -> Fagaras -> Sibiu -> Arad -> Zerind
Bucharest -> Fagaras -> Sibiu -> Arad -> Timisoara
Question 2
a.
State representation: a 9-digit series corresponding to current configuration of the board in the left-to-
right and top-to-bottom manner, 0 represents the blank. For example, the setting in Figure 2 can be
represented as 540618732.
Start state: 540618732
Goal state: 123804765
Operators:
- Move the tile up: 123804765 123864705
- Move the tile down: 123804765 103824765
- Move the tile left: 123804765 123840765
- Move the tile right: 123804765 123084765
540618732 {504618732; 548610732}
b.
State representation: a 2-D array representing an arrangement of 8 queens, onein each column. For
example: (O for blank, X for queen)
XOOOOOOO
OOOOXOOO
OXOOOOOO
OOOOOXOO
OOXOOOOO
OOOXOOOO
OOOOOOXO
OOOOOOOX
Start state: Any state satisfies the state representation above.
Goal state: An arrangement of 8 queens such that none of them is ableto capture any others.
Operator: move any attacked queen to another square in the same column.
XOOOOOOO XOOOOOOO
OOOOXOOO OOOOXOOO
OXOOOOOO OXOOOOOO
OOOOOXOO OOOOOXOO
OOXOOOOO OOXOOOOO
OOOOOOOO OOOOOOXO
OOOXOOXO OOOXOOOO
OOOOOOOX OOOOOOOX
c.
State representation: a triple (x,y,z) where xand yare respectively the numbers of missionaries and
cannibals remaining in the left bank (0 <= x, y <= 3; x, y ∈N); z is 0 if the boat is currently at the left
bank, otherwise z is 1.
Start state: (3,3,0)
Goal state: (0,0,1)
Operators:
- Two missionaries cross the river: (3,1,0) (1,1,1)
- One missionary crosses the river: (0,1,1) (1,1,0)
- Two cannibals cross the river: (3,3,0) (3,1,1)
- One cannibal crosses the river: (3,1,1) (3,2,0)
- One missionary and one cannibal cross the river: (2,2,1) (3,3,0)
d.
State representation: Each state contains two information, current city, and visited cities. Ex: {Cralova,
[Pitestl, Glurglu]}
Start state: {Bucharest,[]}
Goal state: {Bucharest,[all other cities]}
Operators: Move from city X to city Y – new state will have current city is Y and Y will be add to visited
city
Question 3
a. The 8-puzzle problem:
• Is the problem decomposable? No
• Can solution steps be ignored or undone? Can be undone
• Is the universe predictable? Yes
• Is a good solution absolute or relative? Absolute
• Is the solution a state or a path? A path
• What is the role of knowledge? Very little
• Does the task require human-interaction? No
b. The 8-queens problem:
• Is the problem decomposable? No
• Can solution steps be ignored or undone? Can be undone
• Is the universe predictable? Yes
• Is a good solution absolute or relative? Absolute
• Is the solution a state or a path? A state
• What is the role of knowledge? Very little
• Does the task require human-interaction? No
c. The missionaries and cannibals problem:
• Is the problem decomposable? No
• Can solution steps be ignored or undone? Can be undone
• Is the universe predictable? Yes
• Is a good solution absolute or relative? Absolute
• Is the solution a state or a path? A path
• What is the role of knowledge? Very little (just the rules for determining legal moves,
constrain the search and speed up the execution of the program)
• Does the task require human-interaction? No
d. Touring problem
Is the problem decomposable? No
• Can solution steps be ignored or undone? Can be undone
• Is the universe predictable? Yes
• Is a good solution absolute or relative? Absolute
• Is the solution a state or a path? A path
• What is the role of knowledge? Very little
• Does the task require human-interaction? No