Midterm II Solution Prof. Mohamed Batouche Department of Computer Science CCIS – King Saud...
-
date post
21-Dec-2015 -
Category
Documents
-
view
228 -
download
0
Transcript of Midterm II Solution Prof. Mohamed Batouche Department of Computer Science CCIS – King Saud...
![Page 1: Midterm II Solution Prof. Mohamed Batouche Department of Computer Science CCIS – King Saud University Saudi Arabia.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6b5503460f94a49a3a/html5/thumbnails/1.jpg)
Midterm IISolution
Prof. Mohamed Batouche
Department of Computer ScienceCCIS – King Saud University
Saudi Arabia
![Page 2: Midterm II Solution Prof. Mohamed Batouche Department of Computer Science CCIS – King Saud University Saudi Arabia.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6b5503460f94a49a3a/html5/thumbnails/2.jpg)
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 be applied in this order.
57
461
382
567
48
321
![Page 3: Midterm II Solution Prof. Mohamed Batouche Department of Computer Science CCIS – King Saud University Saudi Arabia.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6b5503460f94a49a3a/html5/thumbnails/3.jpg)
57
461
382
0+5=5Cutoff = 5
Use DFS
![Page 4: Midterm II Solution Prof. Mohamed Batouche Department of Computer Science CCIS – King Saud University Saudi Arabia.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6b5503460f94a49a3a/html5/thumbnails/4.jpg)
57
461
382
57
46
1
382
0+5=5
1+5=6
Cutoff = 5
up
![Page 5: Midterm II Solution Prof. Mohamed Batouche Department of Computer Science CCIS – King Saud University Saudi Arabia.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6b5503460f94a49a3a/html5/thumbnails/5.jpg)
57
461
382
57
46
1
382
57
461
382
0+5=5
1+5=6
Cutoff = 5
1+4=5
up right
![Page 6: Midterm II Solution Prof. Mohamed Batouche Department of Computer Science CCIS – King Saud University Saudi Arabia.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6b5503460f94a49a3a/html5/thumbnails/6.jpg)
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
![Page 7: Midterm II Solution Prof. Mohamed Batouche Department of Computer Science CCIS – King Saud University Saudi Arabia.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6b5503460f94a49a3a/html5/thumbnails/7.jpg)
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
![Page 8: Midterm II Solution Prof. Mohamed Batouche Department of Computer Science CCIS – King Saud University Saudi Arabia.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6b5503460f94a49a3a/html5/thumbnails/8.jpg)
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
![Page 9: Midterm II Solution Prof. Mohamed Batouche Department of Computer Science CCIS – King Saud University Saudi Arabia.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6b5503460f94a49a3a/html5/thumbnails/9.jpg)
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
![Page 10: Midterm II Solution Prof. Mohamed Batouche Department of Computer Science CCIS – King Saud University Saudi Arabia.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6b5503460f94a49a3a/html5/thumbnails/10.jpg)
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
![Page 11: Midterm II Solution Prof. Mohamed Batouche Department of Computer Science CCIS – King Saud University Saudi Arabia.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6b5503460f94a49a3a/html5/thumbnails/11.jpg)
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
![Page 12: Midterm II Solution Prof. Mohamed Batouche Department of Computer Science CCIS – King Saud University Saudi Arabia.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6b5503460f94a49a3a/html5/thumbnails/12.jpg)
57
461
382
0+5=5Cutoff = 6
Use DFS
![Page 13: Midterm II Solution Prof. Mohamed Batouche Department of Computer Science CCIS – King Saud University Saudi Arabia.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6b5503460f94a49a3a/html5/thumbnails/13.jpg)
57
461
382
57
46
1
382
0+5=5
1+5=6
Cutoff = 6
up
![Page 14: Midterm II Solution Prof. Mohamed Batouche Department of Computer Science CCIS – King Saud University Saudi Arabia.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6b5503460f94a49a3a/html5/thumbnails/14.jpg)
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
![Page 15: Midterm II Solution Prof. Mohamed Batouche Department of Computer Science CCIS – King Saud University Saudi Arabia.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6b5503460f94a49a3a/html5/thumbnails/15.jpg)
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
![Page 16: Midterm II Solution Prof. Mohamed Batouche Department of Computer Science CCIS – King Saud University Saudi Arabia.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6b5503460f94a49a3a/html5/thumbnails/16.jpg)
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
![Page 17: Midterm II Solution Prof. Mohamed Batouche Department of Computer Science CCIS – King Saud University Saudi Arabia.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6b5503460f94a49a3a/html5/thumbnails/17.jpg)
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
![Page 18: Midterm II Solution Prof. Mohamed Batouche Department of Computer Science CCIS – King Saud University Saudi Arabia.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6b5503460f94a49a3a/html5/thumbnails/18.jpg)
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
![Page 19: Midterm II Solution Prof. Mohamed Batouche Department of Computer Science CCIS – King Saud University Saudi Arabia.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6b5503460f94a49a3a/html5/thumbnails/19.jpg)
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
![Page 20: Midterm II Solution Prof. Mohamed Batouche Department of Computer Science CCIS – King Saud University Saudi Arabia.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6b5503460f94a49a3a/html5/thumbnails/20.jpg)
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
![Page 21: Midterm II Solution Prof. Mohamed Batouche Department of Computer Science CCIS – King Saud University Saudi Arabia.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6b5503460f94a49a3a/html5/thumbnails/21.jpg)
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
![Page 22: Midterm II Solution Prof. Mohamed Batouche Department of Computer Science CCIS – King Saud University Saudi Arabia.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6b5503460f94a49a3a/html5/thumbnails/22.jpg)
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
![Page 23: Midterm II Solution Prof. Mohamed Batouche Department of Computer Science CCIS – King Saud University Saudi Arabia.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6b5503460f94a49a3a/html5/thumbnails/23.jpg)
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=8Goal !!
![Page 24: Midterm II Solution Prof. Mohamed Batouche Department of Computer Science CCIS – King Saud University Saudi Arabia.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6b5503460f94a49a3a/html5/thumbnails/24.jpg)
Question 2• Explain the way to use hill
climbing 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 by modifying region color.
• When to stop:– Stop when the next solution is not
better than current solution (local minimum)
![Page 25: Midterm II Solution Prof. Mohamed Batouche Department of Computer Science CCIS – King Saud University Saudi Arabia.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6b5503460f94a49a3a/html5/thumbnails/25.jpg)
Question 3
• Consider the following map. The task is to color the map using the four colors blue, green, red, and yellow such 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
![Page 26: Midterm II Solution Prof. Mohamed Batouche Department of Computer Science CCIS – King Saud University Saudi Arabia.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6b5503460f94a49a3a/html5/thumbnails/26.jpg)
Question 3Solution
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
![Page 27: Midterm II Solution Prof. Mohamed Batouche Department of Computer Science CCIS – King Saud University Saudi Arabia.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6b5503460f94a49a3a/html5/thumbnails/27.jpg)
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 V2 1
v3 1 V4 4
3 4 1 2
v5 V6 4 V7
• Solve this problem using Backtracking with Arc Consistency
![Page 28: Midterm II Solution Prof. Mohamed Batouche Department of Computer Science CCIS – King Saud University Saudi Arabia.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6b5503460f94a49a3a/html5/thumbnails/28.jpg)
Question 4Solution
v1
v7v6v5
v4v3
v2
{2}{4}
{2}
{1}
{2}
{3}
{3}
4 3 2 1
2 1 3 4
3 4 1 2
1 2 4 3