0% found this document useful (0 votes)
34 views

Breadth First Search Animat Ion

Breadth first search is an algorithm for traversing or searching tree or graph data structures. It begins at a root node and explores all neighboring nodes at the present depth prior to moving to the nodes at the next depth level. The key steps are to (1) initialize a queue with the root node, (2) dequeue nodes and add their neighbors to the back of the queue, (3) repeat until the queue is empty. This process allows exploring nodes level-by-level from the root downwards.

Uploaded by

jeanneta olivia
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Breadth First Search Animat Ion

Breadth first search is an algorithm for traversing or searching tree or graph data structures. It begins at a root node and explores all neighboring nodes at the present depth prior to moving to the nodes at the next depth level. The key steps are to (1) initialize a queue with the root node, (2) dequeue nodes and add their neighbors to the back of the queue, (3) repeat until the queue is empty. This process allows exploring nodes level-by-level from the root downwards.

Uploaded by

jeanneta olivia
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 25

Breadth First Search

Breadth first search animat 1


Initialize

2 4 8

1 1 5 7

pred(1) =all
Unmark 0
nodes in N; 3 6 9
next := 1
Mark node
order(1) = next
s
LIST:= {1}

LIST 1

next 1
Breadth first search animat 2
Select a node i in LIST

2 4 8

1 1 5 7

In breadth
first search, i 3 6 9
is the first
node in LIST

LIST 1

next 1
Breadth first search animat 3
If node i is incident to an admissible arc…
2 2 4 8

1 1 5 7
Next :=Node
Select
Mark an j
Next + 1
admissible 9
pred(j) := i 3 6
arc (i,j):= next
order(j)
add j to LIST

LIST 1 2

next 2
1
Breadth first search animat 4
If node i is incident to an admissible arc…
2 2 4 8

1 1 5 7
3
Next :=Node
Select
Mark an j
Next + 1
admissible 9
pred(j) := i 3 6
arc (i,j):= next
order(j)
add j to LIST

LIST 1 2 5

next 3
2
Breadth first search animat 5
If node i is incident to an admissible arc…
2 2 4 8

1 1 5 7
3
Next :=Node
Select
Mark an j
Next + 1 9
admissible 3 6
pred(j) := i 4
arc (i,j):= next
order(j)
add j to LIST

LIST 1 2 5 3

next 3
2
4
Breadth first search animat 6
If node i is not incident to an admissible arc…
2 2 4 8

1 1 5 7
3

Delete node i 3 6 9
from LIST 4

LIST 1 2 5 3

next 3
2
4
Breadth first search animat 7
Select Node i
2 2 4 8

1 1 5 7
3

The first node 3 6 9


on LIST 4
becomes
node i

LIST 1 2 5 3

next 3
2
4
Breadth first search animat 8
If node i is incident to an admissible arc…
2 2 5
4 8

1 1 5 7
3
Next :=Node
Select
Mark an j
Next + 1
admissible 9
pred(j) := i 3 6
arc (i,j):= next
order(j) 4
add j to LIST

LIST 1 2 5 3 4

next 3
2
4
5
Breadth first search animat 9
If node i is not incident to an admissible arc…
2 2 5
4 8

1 1 5 7
3
Delete node i
from LIST 3 6 9
4

LIST 1 2 5 3 4

next 3
2
4
5
Breadth first search animat 10
Select a node
2 2 5
4 8

1 1 5 7
3
The first node
on LIST 3 6 9
becomes 4
node i

LIST 1 2 5 3 4

next 3
2
4
5
Breadth first search animat 11
If node i is incident to an admissible arc…
2 2 5
4 8

1 1 5 7
3
Next :=Node
Select
Mark an j
Next + 1
admissible 9
pred(j) := i 3 6
arc (i,j):= next
order(j) 4 6
add j to LIST

LIST 1 2 5 3 4 6

next 3
2
4
5
6
Breadth first search animat 12
If node i is not incident to an admissible arc…
2 2 5
4 8

1 1 5 7
3
Delete node i
from LIST 3 6 9
4 6

LIST 1 2 5 3 4 6

next 3
2
4
5
6
Breadth first search animat 13
Select node 3
2 2 5
4 8

1 1 5 7
3
node
delete3node
is not3
incident
from LIST to 3 6 9
any 4 6
admissible
arcs

LIST 1 2 5 3 4 6

next 3
2
4
5
6
Breadth first search animat 14
Select a node
2 2 5
4 8

1 1 5 7
3
i:=4
3 6 9
4 6

LIST 1 2 5 3 4 6

next 3
2
4
5
6
Breadth first search animat 15
If node i is incident to an admissible arc…
2 2 5
4 87

1 1 5 7
3
Next :=Node
Select
Mark an j
Next + 1
admissible 9
pred(j) := i 3 6
arc (i,j):= next
order(j) 4 6
add j to LIST

LIST 1 2 5 3 4 6 8

next 3
2
4
5
6
7
Breadth first search animat 16
If node i is not incident to an admissible arc…
2 2 5
4 87

1 1 5 7
3
Delete node i
from LIST 3 6 9
4 6

LIST 1 2 5 3 4 6 8

next 3
2
4
5
6
7
Breadth first search animat 17
Select node i
2 2 5
4 87

1 1 5 7
3
i := 6
3 6 9
4 6

LIST 1 2 5 3 4 6 8

next 3
2
4
5
6
7
Breadth first search animat 18
If node i is incident to an admissible arc…
2 2 5
4 87

1 1 5 7 8
3
Next :=Node
Select
Mark an j
Next + 1
admissible 9
pred(j) := i 3 6
arc (i,j):= next
order(j) 4 6
add j to LIST

LIST 1 2 5 3 4 6 8 7

next 3
2
4
5
6
7
8
Breadth first search animat 19
If node i is incident to an admissible arc…
2 2 5
4 87

1 1 5 7 8
3
Next :=Node
Select
Mark an j
Next + 1
admissible 9
pred(j) := i 3 6
arc (i,j):= next
order(j) 4 6 9
add j to LIST

LIST 1 2 5 3 4 6 8 7 9

next 3
2
4
5
6
7
8
9
Breadth first search animat 20
If node i is not incident to an admissible arc…
2 2 5
4 87

1 1 5 7 8
3
Delete node i
from LIST 3 6 9
4 6 9

LIST 1 2 5 3 4 6 8 7 9

next 3
2
4
5
6
7
8
9
Breadth first search animat 21
Select node 8
2 2 5
4 87

1 1 5 7 8
3
node 8 is not
incident to an 3 6 9
admissible 4 6 9
arc; delete it
from LIST

LIST 1 2 5 3 4 6 8 7 9

next 3
2
4
5
6
7
8
9
Breadth first search animat 22
Select node 7
2 2 5
4 87

1 1 5 7 8
3
node 7 is not
incident to an 3 6 9
admissible 4 6 9
arc; delete it
from LIST

LIST 1 2 5 3 4 6 8 7 9

next 3
2
4
5
6
7
8
9
Breadth first search animat 23
Select node 9
2 2 5
4 87

1 1 5 7 8
3
node 9 is not
incident to an 3 6 9
admissible 4 6 9
arc; delete it
from LIST

LIST 1 2 5 3 4 6 8 7 9

next 3
2
4
5
6
7
8
9
Breadth first search animat 24
THE END

Breadth first search animat 25

You might also like