You are on page 1of 10

Artificial Intelligence

Algorithms issues
Figure 2
g = 80 S g = 25

h = 30 h = 55

g=0

A h = 100
B

G1 C D G2

g = 85 g = 90 g = 30 g = 70

h=0 h = 20 h = 80 h=0

Path costs for each node


g(S) = 0 , h(S) = 100 , f(S) = 100
g(A) = 80 , h(A) = 30 , f(A) = 110
g(B) = 25 , h(B) = 55 , f(B) = 80
g(G1) = 85 , h(G1) = 0 , f(G1) = 85
g(C) = 90 , h(C) = 20 , f(C) = 110
g(D) = 30 , h(D) = 80 , f(D) = 110
g(G2) = 70 , h(G2) = 0 , f(G2) = 70

36 – f(x) = g(x) + h(x)


g(x) --> is the path from the initial state to node
H(x) --> is the path from the node to the goal state
F(x) --> is the path from the initial state to goal state
Initial state = S
Two goal states = G1,G2
g(x) for node C = 90 , h(x) for node C = 20 (given)
f(x) = 90 + 20 = 110

37- BFS --> breadth first --> level by level


Order = S-A-B-G1
38- DFS--> depth first
Order = S-A-G1
Notes : BFS , DFS don’t use costs , while USC , GBF , A* use costs
• g(x) = f(x) if h(x) = 0 --> node is goal
• g(x) = 0 if the node is the initial node

39- cost (g) = the path from start to node


UCS --> Chooses the least cost (g)
Order = S-B-D-G2
40- cost (h) = the path from node to goal
GBF --> chooses the least cost (h)
Order = S-A-G1
41- cost (f) = the path from initial state to goal state
A* --> chooses the least cost (f)
Order = S-B-G2
Figure 3
MAX A

MIN B 3 3

MAX 4 5 7 3 9 C 8 3 4

MIN 1 2 5 1 9

A=4,B=4,C=9
Figure 4
B

D
E F

DFS use stack --> LIFO


BFS use queue --> FIFO
If B is not the goal :
DFS : B A C (frontier) --> D E F A C , BFS : B A C (frontier) --> A C D E F
If B is the goal :
BFS : B A C --> A C

You might also like