Docsity

Depth First Search and Breadth First Search Algorithms: A Comprehensive Guide, Lecture notes of Discrete Mathematics

Partial preview of the text

Download Depth First Search and Breadth First Search Algorithms: A Comprehensive Guide and more Lecture notes Discrete Mathematics in PDF only on Docsity!

Depth First Search Depth First Search Method

  • (^) When a state is examined, all of its children and their descendants are examined before any of its siblings
  • (^) The siblings are considered only when no further descendants of a state can be found

AI: Chapter 3: Solving Problems by Searching

Depth first search (DFS)

Depth first search (DFS)

Now G,E will be popped. Depth first search (DFS)

Depth first search (DFS)

Breadth first search (BFS)

Breadth first search (BFS)

Breadth first search (BFS)

Breadth first search (BFS)

Breadth First Search

A B

F

I

E H

C D

G

FIFO Queue

-

front

14 AI: Chapter 3: Solving Problems by Searching

Breadth First Search

A B

F

I

E H

C D

G

A

FIFO Queue

- dequeue next vertex front

16 AI: Chapter 3: Solving Problems by Searching

Breadth First Search

visit neighbors of A front

A B

F

I

E H

C D

G

- FIFO Queue

17 AI: Chapter 3: Solving Problems by Searching

Breadth First Search

B discovered front B

A B

F

I

E H

C D

G

- A FIFO Queue

19 AI: Chapter 3: Solving Problems by Searching

Breadth First Search

visit neighbors of A front B

A

F

I

E H

C D

G

- B A FIFO Queue

20 AI: Chapter 3: Solving Problems by Searching