Final Flashcards

(38 cards)

1
Q

Which data structure is used in BFS?

A

Queue

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

Is BFS suitable for finding the shortest path in an unweighted graph?

A

Yes

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

What is the time complexity of BFS in terms of V and E?

A

O(V + E)

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

Does BFS visit all nodes in a disconnected graph?

A

No

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

Which data structure is used in DFS (iterative)?

A

Stack

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

DFS can be used to detect cycles in which type of graph?

A

Both directed and undirected graphs

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

In DFS

A

what can be used to find articulation points and bridges?

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

What is the time complexity of DFS?

A

O(V + E)

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

Topological sorting applies to which type of graph?

A

Directed Acyclic Graph (DAG)

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

Which algorithms can perform topological sort?

A

Kahn’s Algorithm (BFS) and DFS-based

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

What is the order of nodes in topological sort useful for?

A

Task scheduling / dependency resolution

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

Topological sort is not possible if the graph has a

A

Cycle

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

A spanning tree must include all

A

Vertices with minimum number of edges

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

Number of edges in a spanning tree with n vertices is

A

n - 1

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

Can a graph have more than one spanning tree?

A

Yes

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

What is a minimum spanning tree?

A

A spanning tree with minimum total edge weight

17
Q

What is an articulation point in a graph?

A

A vertex whose removal increases the number of connected components

18
Q

Which algorithm is commonly used to find articulation points?

A

DFS with low-link values

19
Q

Articulation points exist only in

A

Connected undirected graphs

20
Q

Can a leaf node be an articulation point?

21
Q

What are two common algorithms to find MST?

A

Prim’s and Kruskal’s

22
Q

Can an MST exist in a disconnected graph?

23
Q

Is MST unique for every graph?

24
Q

Prim’s algorithm grows the MST by adding

A

The smallest edge connecting the tree to an outside vertex

25
Which data structure is used to improve Prim's efficiency?
Priority Queue (Min Heap)
26
Time complexity of Prim's using min-heap and adjacency list
O(E log V)
27
Kruskal’s algorithm uses which data structure to detect cycles?
Disjoint Set (Union-Find)
28
Kruskal’s sorts all edges based on
Weight
29
Kruskal’s is best suited for
Sparse graphs
30
Dijkstra’s algorithm works only when all edge weights are
Non-negative
31
What is the time complexity using a binary heap?
O((V + E) log V)
32
Does Dijkstra’s algorithm guarantee shortest paths?
Yes
33
Bellman-Ford can handle
Graphs with negative weights
34
Time complexity of Bellman-Ford is
O(V × E)
35
It can detect
Negative weight cycles
36
Floyd-Warshall is used for
All-pairs shortest paths
37
It works with
Negative weights
38
Time complexity of Floyd-Warshall
O(V³)