Graph-traversal algorithms Flashcards

You may prefer our related Brainscape-certified 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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does a depth-first traversal use?

A

It uses a stack with a recursive or non recursive routine

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does a breadth-first traversal use?

A

It uses a queue with an iterative routine

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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..

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are some applications of depth-first traversals?

A
  • Used in solving problems such as mazes which can be represented as graphs
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly