djikstras shortest path algorithm Flashcards

(23 cards)

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

What are the properties of graphs?

A

Graph properties can be:
* Connected
* Weighted
* Non-negative
* Directed

Directed graphs can have edges that go in one direction only.

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

What does the variable ‘n’ represent in graph theory?

A

Number of Nodes

‘n’ denotes the total count of vertices in the graph.

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

What does the variable ‘m’ represent in graph theory?

A

Number of edges

‘m’ denotes the total count of edges connecting the nodes.

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

Define a path in graph theory.

A

Edge of one vertex connects to the next, can be followed from a source to a destination.

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

What is the shortest path?

A

Minimum total sum of edge weights.

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

What are the types of path problems?

A

Types of path problems include:
* Single-pair shortest path
* Single-source shortest path
* All-pairs shortest path

Each type addresses different shortest path queries in a graph.

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

What is the single-pair shortest path problem?

A

Find shortest path between specific vertices v and u.

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

What is the single-source shortest path problem?

A

Shortest path from specific vertex v to all other nodes.

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

What is the all-pairs shortest path problem?

A

Shortest paths between all pairs of nodes.

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

What formula gives the total amount of edges in a graph?

A

(n-1)^2

This formula estimates the maximum number of edges in a complete graph.

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

What is true about any prefix of the shortest path?

A

Any prefix of the shortest path from v is also a shortest path from v.

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

What is the main concept of Dijkstra’s algorithm?

A

Incrementally adding nodes that we know are the shortest path.

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

How does Dijkstra’s algorithm expand the set of nodes?

A

Find node that can be reached by a single edge from the current set, with the minimum total weight over the whole shortest path.

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

What do Dist(u) and Pre(u) represent in Dijkstra’s algorithm?

A

Dist(u) = distance of shortest v -> u path found so far; Pre(u) = predecessor of u on the shortest path v -> u path so far.

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

In Dijkstra’s algorithm, what is the initial distance for the source node?

17
Q

What is the initial distance for all other nodes in Dijkstra’s algorithm?

A

dist(u) = infinity for all u != v.

18
Q

What is the total complexity of Dijkstra’s algorithm using simple data structures?

19
Q

What is the total complexity of Dijkstra’s algorithm when using binary heaps or BST?

20
Q

What is an important condition for Dijkstra’s algorithm to work correctly?

A

Edge weights must be non-negative.

21
Q

What should be used if negative edge weights are present?

A

Slower algorithms must be used.

22
Q

What is the total average time complexity?

Big O

23
Q

What is the total average time complexity of djikstras with a heap/bst?

A

O( m log n)

m is number of edges, n is number of nodes