Breadth First Search Flashcards

1
Q

Graph

A

Models connections. Composed of nodes and edges

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

Shortest-path-problem

A

Solved by breadth first search algorithm

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

Questions breadth first search can answer

A

Is there a path from Node A to Node B

What is the shortest path between two nodes

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

Breadth-first-search algorithm

A

Uses a queue to search first degree connection, then 2nd degree connections then 3rd degree etc.

Keep a list of nodes you have already checked to avoid an infinite loop.

Add connections of nodes to end of queue

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

Queue

A

Data structure like a line. The first in line is the first to leave
Enqueue
Dequeue

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

Enqueue

A

Like push()
Add to end of queue

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

Dequeue

A

Remove from start of queue

Like pop()

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

Queue vs stack

A

Stacks are LIFO - stack of books
Queues are FIFO - line of people

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

Implementation of graph

A

A hash of nodes to their 1st degree connections

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

Directed vs undirected graphs

A

Directed graphs are 1 way

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

Breadth first search runtime

A

O(Vertices+ edges)

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

Topological sort

A

A graph where if node A depends on node B, it will appear later in the list

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

Tree

A

A type of graph where edges don’t point back to nodes

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