midterm ii solution
TRANSCRIPT
-
8/12/2019 Midterm II Solution
1/28
Midterm II
Solution
Prof. Mohamed Batouche
Department of Computer Science
CCIS
King Saud UniversitySaudi Arabia
-
8/12/2019 Midterm II Solution
2/28
Question 1
Solve the 8-puzzle problem using
IDA* with h1() heuristic:
Operators: slide-blank-up, slide-
blank-down, slide-blank-right, slide-
blank-left. Operators should beapplied in this order.
57
461
382
567
48
321
-
8/12/2019 Midterm II Solution
3/28
57
461
382
0+5=5Cutoff = 5
Use DFS
-
8/12/2019 Midterm II Solution
4/28
57
461
382
57
46
1
382
0+5=5
1+5=6
Cutoff = 5
up
-
8/12/2019 Midterm II Solution
5/28
57
461
382
57
46
1
382
57
461
382
0+5=5
1+5=6
Cutoff = 5
1+4=5
up right
-
8/12/2019 Midterm II Solution
6/28
57
461
382
57
46
1
382
57
461
382
57
4
6
1
382
0+5=5
1+5=6
Cutoff = 5
1+4=5
2+3=5
up
up
right
-
8/12/2019 Midterm II Solution
7/28
57
461
382
57
46
1
382
57
461
382
57
4
6
1
382
57
4
6
1
3
8
2
0+5=5
1+5=6
Cutoff = 5
1+4=5
2+3=5
3+3=6
up
up
up
right
-
8/12/2019 Midterm II Solution
8/28
57
461
382
57
46
1
382
57
461
382
57
4
6
1
382
57
4
6
1
382
57
4
6
1
3
8
2
0+5=5
1+5=6
Cutoff = 5
1+4=5
2+3=5
3+3=6 3+4=7
up
up
up
right
right
-
8/12/2019 Midterm II Solution
9/28
57
461
382
57
46
1
382
57
461
382
57
4
6
1
382
57
4
6
1
382
57
4
6
1
3
8
2
57
4
6
1
382
0+5=5
1+5=6
Cutoff = 5
1+4=5
2+3=5
3+3=6 3+3=63+4=7
up
up
up
right
right left
-
8/12/2019 Midterm II Solution
10/28
57
461
382
57
46
1
382
57
461
382
57
461
382
57
4
6
1
382
57
4
6
1
382
57
4
6
1
3
8
2
57
4
6
1
382
0+5=5
1+5=6
Cutoff = 5
1+4=5
2+3=5 2+5=7
3+3=6 3+3=63+4=7
up
up
up
right
right
right left
-
8/12/2019 Midterm II Solution
11/28
57
461
382
57
46
1
382
57
461
382
57
461
382
57
4
6
1
382
57
4
6
1
382
57
4
6
1
3
8
2
57
4
6
1
382
0+5=5
1+5=6
Cutoff = 5
1+4=5
2+3=5 2+5=7
3+3=6 3+3=63+4=7
Failure: Change cutoff min(f(leaves)) = 6
up
up
up
right
right
right left
-
8/12/2019 Midterm II Solution
12/28
57
461
382
0+5=5Cutoff = 6
Use DFS
-
8/12/2019 Midterm II Solution
13/28
57
461
382
57
46
1
382
0+5=5
1+5=6
Cutoff = 6
up
-
8/12/2019 Midterm II Solution
14/28
57
461
382
57
46
1
382
0+5=5
1+5=6
Cutoff = 6
up
57
46
1
38
2
2+5=7
up
-
8/12/2019 Midterm II Solution
15/28
57
461
382
57
46
1
382
0+5=5
1+5=6
Cutoff = 6
up
57
46
1
38
2
57
46
1
382
2+5=7 2+5=7
upright
-
8/12/2019 Midterm II Solution
16/28
57
461
382
57
46
1
382
57
461
382
0+5=5
1+5=6
Cutoff = 6
1+4=5
up right
57
46
1
38
2
57
46
1
382
2+5=7 2+5=7
upright
-
8/12/2019 Midterm II Solution
17/28
57
461
382
57
46
1
382
57
461
382
57
4
6
1
382
0+5=5
1+5=6
Cutoff = 6
1+4=5
2+3=5
up
up
right
57
46
1
38
2
57
46
1
382
2+5=7 2+5=7
upright
-
8/12/2019 Midterm II Solution
18/28
57
461
382
57
46
1
382
57
461
382
57
4
6
1
382
57
4
6
1
3
8
2
0+5=5
1+5=6
Cutoff = 6
1+4=5
2+3=5
3+3=6
up
up
up
right
57
46
1
38
2
57
46
1
382
2+5=7 2+5=7
upright
-
8/12/2019 Midterm II Solution
19/28
57
461
382
57
46
1
382
57
461
382
57
4
6
1
382
57
4
6
1
3
8
2
0+5=5
1+5=6
Cutoff = 6
1+4=5
2+3=5
3+3=6
up
up
up
right
57
46
1
38
2
57
46
1
382
2+5=7 2+5=7
upright
57
4
6
1
3
8
2
right
4+4=8
-
8/12/2019 Midterm II Solution
20/28
57
461
382
57
46
1
382
57
461
382
57
4
6
1
382
57
4
6
1
3
8
2
0+5=5
1+5=6
Cutoff = 6
1+4=5
2+3=5
3+3=6
up
up
up
right
57
46
1
38
2
57
46
1
382
2+5=7 2+5=7
upright
57
4
6
1
3
8
2
57
4
6
1
3
8
2
right
left4+4=8
4+2=6
-
8/12/2019 Midterm II Solution
21/28
57
461
382
57
46
1
382
57
461
382
57
4
6
1
382
57
4
6
1
3
8
2
0+5=5
1+5=6
Cutoff = 6
1+4=5
2+3=5
3+3=6
up
up
up
right
57
46
1
38
2
57
46
1
382
2+5=7 2+5=7
upright
57
4
6
1
3
8
2
57
4
6
1
3
8
2
right
left
57
4
6
1 3
8
2
down
4+4=8
4+2=6
5+1=6
-
8/12/2019 Midterm II Solution
22/28
57
461
382
57
46
1
382
57
461
382
57
4
6
1
382
57
4
6
1
3
8
2
0+5=5
1+5=6
Cutoff = 6
1+4=5
2+3=5
3+3=6
up
up
up
right
57
46
1
38
2
57
46
1
382
2+5=7 2+5=7
upright
57
4
6
1
3
8
2
57
4
6
1
3
8
2
right
left
57
4
6
1 3
8
2
down
5
7 4
6
1 3
8
2
down
4+4=8
4+2=6
5+1=6
6+2=8
-
8/12/2019 Midterm II Solution
23/28
57
461
382
57
46
1
382
57
461
382
57
4
6
1
382
57
4
6
1
3
8
2
0+5=5
1+5=6
Cutoff = 6
1+4=5
2+3=5
3+3=6
up
up
up
right
57
46
1
38
2
57
46
1
382
2+5=7 2+5=7
upright
57
4
6
1
3
8
2
57
4
6
1
3
8
2
right
left
57
4
6
1 3
8
2
down
5
7 4
6
1 3
8
2
down right
567
48
321
4+4=8
4+2=6
5+1=6
6+2=8
Goal !!
-
8/12/2019 Midterm II Solution
24/28
Question 2
Explain the way to use hillclimbing for map coloring:
How to start: Start with random solution: assign
randomly colors to regions
How to improve current solution Select the best solution (minconflicts)
in the neighborhood obtained bymodifying region color.
When to stop: Stop when the next solution is not
better than current solution (localminimum)
-
8/12/2019 Midterm II Solution
25/28
Question 3
Consider the following map. The task is to color
the map using the four colors blue, green, red,
and yellowsuch that no two adjacent regions take
the same color.
Color the map using Backtracking Search with
MCV. Show the steps. The values should be
selected according to alphabetical order: (blue,green, red, yellow)
1
4
2
3 6
5
-
8/12/2019 Midterm II Solution
26/28
Question 3
Solution
1
4
2
3 6
5
Order of variable selection using MCV (select first
the variable with most constraints on remaining
variables):
2, 1, 3, 5, 4, 6
-
8/12/2019 Midterm II Solution
27/28
Question 4
Consider the problem of Sudoku where:
No value appears twice in the same row.
No value appears twice in the same column.
No value appears twice in the same block(22 block).
v1 3 V
2 1
v3 1 V4 4
3 4 1 2
v5 V6 4 V7
Solve this problem using Backtracking with Arc
Consistency
-
8/12/2019 Midterm II Solution
28/28
Question 4
Solutionv1
v7v
6v
5
v4v
3
v2
{2}{4}
{2}
{1}
{2}
{3}
{3}
4 3 2 1
2 1 3 4
3 4 1 2