Breadth First Search Instructor Prof JyhShing Roger Jang
Breadth First Search Instructor : Prof. Jyh-Shing Roger Jang Designer:Shao-Huan Wang The ideas are reference to the textbook “Fundamentals of Data Structures in C “.
Breadth First Search FR FR 0 1 0 2 R 1 Prepare a queue to record the nodes Print the first node and remark it visited 3 4 5 7 01 6 Push the first node to queue Get node from queue 0. If the linked nodes are not visited: 1. Print the node 2. Push to queue 3. Remark it visited
Breadth First Search 0 F visited 1 2 FR R 1 2 R 3 Prepare a queue to record the nodes Print the first node and remark it visited 3 4 5 7 0123 6 Push the first node to queue Get node from queue 0. If the linked nodes are not visited: 1. Print the node 2. Push to queue 3. Remark it visited 4. Find the other linked nodes and go to the step 0 5. If finished all the linked nodes, get another node from queue and go to step 0
Breadth First Search 0 R visited 1 5 2 F F R 2 3 R 4 Prepare a queue to record the nodes Print the first node and remark it visited 3 4 5 7 012345 6 Push the first node to queue Get node from queue 0. If the linked nodes are not visited: 1. Print the node 2. Push to queue 3. Remark it visited 4. Find the other linked nodes and go to the step 0 5. If finished all the linked nodes, get another node from queue and go to step 0
Breadth First Search R 0 1 5 2 visited R 6 R F 7 F 3 4 Prepare a queue to record the nodes Print the first node and remark it visited 3 4 5 7 01234567 6 Push the first node to queue Get node from queue 0. If the linked nodes are not visited: 1. Print the node 2. Push to queue 3. Remark it visited 4. Find the other linked nodes and go to the step 0 5. If finished all the linked nodes, get another node from queue and go to step 0
Breadth First Search F 0 1 2 visited 5 F 6 R F 7 Prepare a queue to record the nodes Print the first node and remark it visited 3 4 5 7 01234567 visited 6 Push the first node to queue Get node from queue 0. If the linked nodes are not visited: 1. Print the node 2. Push to queue 3. Remark it visited 4. Find the other linked nodes and go to the step 0 5. If finished all the linked nodes, get another node from queue and go to step 0
Breadth First Search F R 0 1 2 Prepare a queue to record the nodes Print the first node and remark it visited 3 visited 4 5 7 01234567 visited Push the first node to queue 6 visited Get node from queue 0. If the linked nodes are not visited: 1. Print the node 2. Push to queue 3. Remark it visited 4. Find the other linked nodes and go to the step 0 5. If finished all the linked nodes, get another node from queue and go to step 0
- Slides: 7