Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 4)
- BFS:
- Step 1: 1:=0
- Q: 2,4,3
- Step 2: 2:=1
- Q: 4,3
- Step 3: 4:=1
- Q: 3
- Step 4: 3:=1
- Q: 6,5
- Step 5: 6:=2
- Q: 5
- Step 6: 5:=2
- Q: ∅
- 7)
- Algorithm for detecting cycles in undirected graph:
- - Enqueue starting vertex
- - For as long as there are vertices in the queue:
- -
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement