(1) Breadth-First Search S Queue S We begin with S on the queue. Note that as nodes come off the queue (expanded), their children are placed on the queue. In breadth-first search, the new nodes are always placed at the end of the queue Breadth-First Search
(1) (2) Breadth-First Search A, F Queue S A F A will be expanded next since it is in front of the queue. Its children are placed at the end of the queue. Breadth-First Search
(1) (2) (3) Breadth-First Search F, C, F Queue S A F C F Note that S is not listed as a child of A because it was already expanded earlier. Breadth-First Search
C, F, G, H Queue (1) S (2) (3) A F C F G H Breadth-First Search
(1) (2) (3) (4) Breadth-First Search F, G, H, D, G Queue S A F C F G
(1) (2) (3) (4) Breadth-First Search G, H, D, G Queue S A F C F G H Will not expand this because it was already expanded earlier; we can eliminate it from the queue. Breadth-First Search
(1) (2) (3) (4) (5) Breadth-First Search G, H, D, G Queue S A F C G
(1) (2) (3) (4) (5) S F G Breadth-First Search S A C F G H D Since G is expanded (comes off the queue), and it is a goal node, we are done. The solution found by the search algorithm is: S F G Breadth-First Search
(1) Depth-First Search S Queue S Depth-first search works the same way except that the children of a node that is expanded are always placed in front of the queue (so they take priority over nodes that were already on the queue. Depth-First Search
A, F Queue (1) S (2) A F Depth-First Search
(1) (2) Depth-First Search C, F2, F1 Queue S A F1 C F2 Note that S is not listed as a child of A because it was already expanded earlier. The subscript for F is only so that we can distinguish between the two instances of F on the queue (but they represent the same F node). Depth-First Search
D, G, F2, F1 Queue (1) S (2) A F1 (3) C F2 D G Depth-First Search
(1) (2) (3) (4) Depth-First Search G, F2, F1 Queue S A F1 C F2 Note that D only has G as a child that has not yet been expanded. We use subscripts again to distinguish between different instance of G on the queue. D (4) G Depth-First Search
(1) (2) (3) (4) Depth-First Search G2, G1, F2, F1 Queue S A F1 C F2 Note that D only has G as a child that has not yet been expanded. We use subscripts again to distinguish between different instance of G on the queue. D (4) G1 G2 Depth-First Search
(1) (2) (3) (4) S A C D G (5) Depth-First Search G1, F2, F1 Queue S A C F2 F1 (2) (1) (3) D G1 (4) G2 (5) Since G comes off the queue and it is a goal node, we stop. The solution found by the algorithm is: S A C D G Depth-First Search
A, F Queue (1) S 7 2 F 7 A 2 In uniform const search, the queue is always ordered in the increasing costs (i.e., increasing values of g(n) for each node n). The cost value of a node n is computed as the total cost of getting from the start node S to node n. The g(n) values are shown in black boxes. Uniform Cost Search
A, F Queue (1) S 7 2 (2) F 7 A 2 Uniform Cost Search
C, F1, F2 Queue (1) S 7 2 (2) F1 7 A 2 4 8 C 6 F2 10 Note that the queue gets ordered according to costs with lowest cost node in front. So, C is the next node to be expanded. Uniform Cost Search
(1) (2) (3) F1, D, F2, G Queue S F1 A C F2 D G Uniform Cost Search 7 4 8 (3) C 6 F2 10 5 3 D 9 G 11 Uniform Cost Search
(1) (4) (2) (3) D, H, F2, G1, G2 Queue S F1 A C F2 G2 H D G1 7 2 (2) (4) F1 7 A 2 4 5 2 8 (3) C 6 F2 10 12 G2 H 9 5 3 D 9 G1 11 Since F has been expanded, we can eliminate other instances of it from the tree and the queue. Uniform Cost Search
(1) (4) (2) (3) D, H, G1, G2 Queue S F1 A C G2 H D G1 7 2 (2) (4) F1 7 A 2 4 5 2 (3) C 6 12 G2 H 9 5 3 D 9 G1 11 Uniform Cost Search
(1) (4) (2) (3) (5) H, G1, G2, G3 Queue S F A C G2 H D G1 G3 7 2 (2) (4) F 7 A 2 4 5 2 (3) C 6 12 G2 H 9 5 3 (5) D 9 G1 11 3 G3 12 Uniform Cost Search
(1) (4) (2) (3) (6) (5) G1, G2, G3 Queue S F A C G2 H D G1 G3 7 2 (2) (4) F 7 A 2 4 5 2 (3) C 6 12 G2 (6) H 9 5 3 (5) D 9 G1 11 3 G3 12 Uniform Cost Search
(1) (4) (2) (3) (6) (5) (7) G2, G3 Queue S F A C G2 H D G1 G3 12 G2 (6) H 9 5 3 (5) D 9 (7) G1 11 3 G3 12 Uniform Cost Search
(1) (4) (2) (3) (6) (5) (7) S A C G S A C F D G1 G2 H G3 11 9 (4) G2 H 12 (5) G3 (6) (7) G2, G3 Queue Since G comes off the queue and it is a goal node, we stop. The solution found by the algorithm is: S A C G Total Cost: 2 + 4 + 5 = 11 Uniform Cost Search
F, A Queue (1) S 5 A F 4 h(n) Greedy Search is similar to uniform cost, but this time, the costs are not considered. Instead the nodes on the queue are ordered in the increasing order of the values of h(n), the heuristic value of node n. The h(n) values are the ones shown in the black boxes. Greedy-Best First Search
G, H, A Queue (1) S 5 A (2) F 4 G H 2 In this case A is not generated as a child of F because it would not have a smaller h value than the version of A already on the queue. Greedy-Best First Search
(1) (2) S F G G, H, A Queue S A F G H 5 A (2) F 4 G H 2 Since G comes off the queue and it is a goal node, we stop. The solution found by the algorithm is: S F G Greedy-Best First Search
A, F Queue h=10 g=0 S 10 2 7 h=5 g=2 7 A h=4 g=7 11 F A* search combines the uniform cost search and the greedy best-first search. Instead of ordering the queue using g(n) values (as in UCS) or ordering only based on the heuristic h(n) (as in greedy search), we order the nodes for expansion in increasing order of f(n) = g(n)+h(n). A* Search
(1) (2) C, F, F Queue S A F C F A* Search 10 2 7 7 11 4 8 10 14 h=10 g=0 (1) S 10 2 (2) 7 h=5 g=2 7 A h=4 g=7 11 F 4 8 h=4 g=2+4 h=4 g=2+8 10 C 14 F A* Search
(1) (2) (3) F(11), G, D, F(14) Queue S A F C F G D A* Search 10 2 7 8 h=4 g=2+4 h=4 g=2+8 10 C 14 F 5 3 h=0 g=11 h=3 g=9 11 G D 12 A* Search
(1) (2) (4) (3) G(11), H, D, G(12), F Queue S A F C F G H G D 10 2 (2) 7 (4) h=5 g=2 7 A h=4 g=7 11 F 4 (3) 8 5 2 h=4 g=2+4 h=4 g=2+8 10 C 14 F h=0 g=12 h=2 g=9 12 G H 11 5 3 h=0 g=11 h=3 g=9 11 G D 12 At this point we can remove the other F from the queue and the tree (but that is not necessary). Since G come off next, we are done with the search. A* Search
The search returns the path S A C G H, D, G Queue h=10 g=0 (1) S 10 2 (2) 7 (4) h=5 g=2 7 A h=4 g=7 11 F 4 5 2 (3) h=4 g=2+4 h=0 g=12 h=2 g=9 10 C 12 G H 11 5 3 (5) h=0 g=11 h=3 g=9 11 G D 12 The search returns the path S A C G A* Search
Missionaries and Cannibals
Sliding Tile with A*