lesson 21/05/20 Graphs traversal algorithms Flashcards
1
Q
What are the 2 approaches of searching a graph
A
Depth-first and breadth-first
2
Q
does Depth-first use a stack or queue
A
Uses a stack
3
Q
does Breadth-first use a stack or queue
A
Uses a queue
4
Q
describe how a depth-first approach works
A
- start at the root of graph
- follow one branch as far as you can go
- backtrack until you find a new route
- repeat until you go through every root
- pop everything off
5
Q
describe how a breadth-first approach works
A
- start at the root of graph
- scan each branch the front of queue has
- pop front when it has no new routes
- repeat until every route has been scanned
- pop everything off
6
Q
examples of a real life depth-first approach
A
GPS Navigation systems, computer Networks (peer-to-peer)