Download presentation
Presentation is loading. Please wait.
1
Midterm II Solution Prof. Mohamed Batouche Department of Computer Science CCIS – King Saud University Saudi Arabia
2
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
3
57 461 382 0+5=5 Cutoff = 5 Use DFS
4
57 461 382 57 46 1 382 0+5=5 1+5=6 Cutoff = 5 up
5
57 461 382 57 46 1 382 5 7 461 382 0+5=5 1+5=6 Cutoff = 5 1+4=5 upright
6
57 461 382 57 46 1 382 5 7 461 382 5 7 4 6 1 382 0+5=5 1+5=6 Cutoff = 5 1+4=5 2+3=5 up right
7
57 461 382 57 46 1 382 5 7 461 382 5 7 4 6 1 382 5 7 4 6 1 3 8 2 0+5=5 1+5=6 Cutoff = 5 1+4=5 2+3=5 3+3=6 up right
8
57 461 382 57 46 1 382 5 7 461 382 5 7 4 6 1 382 5 7 4 6 1 382 5 7 4 6 1 3 8 2 0+5=5 1+5=6 Cutoff = 5 1+4=5 2+3=5 3+3=63+4=7 up right
9
57 461 382 57 46 1 382 5 7 461 382 5 7 4 6 1 382 5 7 4 6 1 382 5 7 4 6 1 3 8 2 5 7 4 6 1 382 0+5=5 1+5=6 Cutoff = 5 1+4=5 2+3=5 3+3=6 3+4=7 up right left
10
57 461 382 57 46 1 382 5 7 461 382 57 461 382 5 7 4 6 1 382 5 7 4 6 1 382 5 7 4 6 1 3 8 2 5 7 4 6 1 382 0+5=5 1+5=6 Cutoff = 5 1+4=5 2+3=52+5=7 3+3=6 3+4=7 up right left
11
57 461 382 57 46 1 382 5 7 461 382 57 461 382 5 7 4 6 1 382 5 7 4 6 1 382 5 7 4 6 1 3 8 2 5 7 4 6 1 382 0+5=5 1+5=6 Cutoff = 5 1+4=5 2+3=52+5=7 3+3=6 3+4=7 Failure: Change cutoff min(f(leaves)) = 6 up right left
12
57 461 382 0+5=5 Cutoff = 6 Use DFS
13
57 461 382 57 46 1 382 0+5=5 1+5=6 Cutoff = 6 up
14
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
15
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 up right
16
57 461 382 57 46 1 382 5 7 461 382 0+5=5 1+5=6 Cutoff = 6 1+4=5 upright 57 46 1 38 2 57 46 1 382 2+5=7 up right
17
57 461 382 57 46 1 382 5 7 461 382 5 7 4 6 1 382 0+5=5 1+5=6 Cutoff = 6 1+4=5 2+3=5 up right 57 46 1 38 2 57 46 1 382 2+5=7 up right
18
57 461 382 57 46 1 382 5 7 461 382 5 7 4 6 1 382 5 7 4 6 1 3 8 2 0+5=5 1+5=6 Cutoff = 6 1+4=5 2+3=5 3+3=6 up right 57 46 1 38 2 57 46 1 382 2+5=7 up right
19
57 461 382 57 46 1 382 5 7 461 382 5 7 4 6 1 382 5 7 4 6 1 3 8 2 0+5=5 1+5=6 Cutoff = 6 1+4=5 2+3=5 3+3=6 up right 57 46 1 38 2 57 46 1 382 2+5=7 up right 5 7 4 6 1 3 8 2 4+4=8
20
57 461 382 57 46 1 382 5 7 461 382 5 7 4 6 1 382 5 7 4 6 1 3 8 2 0+5=5 1+5=6 Cutoff = 6 1+4=5 2+3=5 3+3=6 up right 57 46 1 38 2 57 46 1 382 2+5=7 up right 5 7 4 6 1 3 8 2 5 7 4 6 1 3 8 2 left 4+4=8 4+2=6
21
57 461 382 57 46 1 382 5 7 461 382 5 7 4 6 1 382 5 7 4 6 1 3 8 2 0+5=5 1+5=6 Cutoff = 6 1+4=5 2+3=5 3+3=6 up right 57 46 1 38 2 57 46 1 382 2+5=7 up right 5 7 4 6 1 3 8 2 5 7 4 6 1 3 8 2 left 5 7 4 6 1 3 8 2 down 4+4=8 4+2=6 5+1=6
22
57 461 382 57 46 1 382 5 7 461 382 5 7 4 6 1 382 5 7 4 6 1 3 8 2 0+5=5 1+5=6 Cutoff = 6 1+4=5 2+3=5 3+3=6 up right 57 46 1 38 2 57 46 1 382 2+5=7 up right 5 7 4 6 1 3 8 2 5 7 4 6 1 3 8 2 left 5 7 4 6 1 3 8 2 down 5 7 4 6 1 3 8 2 4+4=8 4+2=6 5+1=6 6+2=8
23
57 461 382 57 46 1 382 5 7 461 382 5 7 4 6 1 382 5 7 4 6 1 3 8 2 0+5=5 1+5=6 Cutoff = 6 1+4=5 2+3=5 3+3=6 up right 57 46 1 38 2 57 46 1 382 2+5=7 up right 5 7 4 6 1 3 8 2 5 7 4 6 1 3 8 2 left 5 7 4 6 1 3 8 2 down 5 7 4 6 1 3 8 2 right 567 48 321 4+4=8 4+2=6 5+1=6 6+2=8 Goal !!
24
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)
25
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)
26
Question 3 Solution Order of variable selection using MCV (select first the variable with most constraints on remaining variables): 2, 1, 3, 5, 4, 6
27
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 (2 2 block). v1v1 3V2V2 1 v31V4V4 4 3412 v5v5 V6V6 4V7V7 Solve this problem using Backtracking with Arc Consistency
28
Question 4 Solution v1v1 v7v7 v6v6 v5v5 v4v4 v3v3 v2v2 {2}{2} {4}{4} {2}{2} {1}{1} {2}{2} {3}{3} {3}{3} 4 3 2 1 2 1 3 4 3412 1 2 4 3
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.