Flashcards in Graph-traversal algorithms Deck (7)

Loading flashcards...

1

Q

What are the two types of way to traverse a graph so that every node is visited?

A

- Depth first

- Breadth first

2

Q

What does a depth-first traversal use?

A

It uses a stack with a recursive or non recursive routine

3

Q

What does a breadth-first traversal use?

A

It uses a queue with an iterative routine

4

Q

How does a depth-first traversal work?

A

We go as far down one route as we can before backtracking and taking the next route

5

Q

How does a breadth-first traversal work?

A

From the current node, visit all the nodes adjacent to it before moving to the next item in the queue and repeating the process for each node at this ‘level’ before moving to the next level..

6

Q

What are some applications of depth-first traversals?

A

- Used in solving problems such as mazes which can be represented as graphs

7

Q

What are some applications of breadth-first traversals?

A

- Used to find the shortest path between two points (used in GPS navigation)
- Webcrawler (they analyse all the sites you can reach by following links randomly on a particular website)