Data Structures

Graphs — Practice MCQs for CCAT

20 Questions Section B: Programming Data Structures

Practice 20 Graphs multiple-choice questions designed for CDAC CCAT exam preparation. Click "Show Answer" to reveal the correct option with detailed explanation.

Q1.
Shortest path in unweighted graph uses:
ADFS
BBFS
CDijkstra
DBellman-Ford
Show Answer & Explanation

Correct Answer: B — BFS

BFS finds shortest path in unweighted graphs by exploring level by level.

Q2.
Dijkstra's algorithm finds:
AMST
BShortest path from single source
CAll pairs shortest path
DCycle detection
Show Answer & Explanation

Correct Answer: B — Shortest path from single source

Dijkstra finds shortest path from single source to all other vertices.

Q3.
DFS uses which data structure?
AQueue
BStack
CPriority Queue
DHeap
Show Answer & Explanation

Correct Answer: B — Stack

DFS uses stack (or recursion which uses call stack).

Q4.
A graph with n vertices can have maximum __ edges (simple, undirected):
An
Bn-1
Cn(n-1)/2
D
Show Answer & Explanation

Correct Answer: C — n(n-1)/2

Maximum edges in simple undirected graph = n(n-1)/2 (complete graph).

Q5.
Topological sort is for:
AAny graph
BUndirected graph
CDAG only
DComplete graph
Show Answer & Explanation

Correct Answer: C — DAG only

Topological sort works only on Directed Acyclic Graphs (DAG).

Q6.
Kruskal's algorithm finds:
AShortest path
BMinimum Spanning Tree
CMaximum flow
DCycle
Show Answer & Explanation

Correct Answer: B — Minimum Spanning Tree

Kruskal's finds MST using greedy approach, selecting smallest edges.

Q7.
Time complexity of BFS with adjacency list:
AO(V)
BO(E)
CO(V+E)
DO(V×E)
Show Answer & Explanation

Correct Answer: C — O(V+E)

BFS visits all vertices and edges once, taking O(V+E) time.

Q8.
A connected graph with V vertices has at least __ edges:
AV
BV-1
CV+1
D2V
Show Answer & Explanation

Correct Answer: B — V-1

Minimum edges for connected graph is V-1 (a tree).

Q9.
Adjacency matrix for n vertices uses __ space:
AO(n)
BO(n²)
CO(log n)
DO(1)
Show Answer & Explanation

Correct Answer: B — O(n²)

Adjacency matrix is n×n, using O(n²) space.

Q10.
Prim's algorithm is used for:
AShortest path
BMST
CCycle detection
DTopological sort
Show Answer & Explanation

Correct Answer: B — MST

Prim's algorithm finds Minimum Spanning Tree.

Q11.
Which algorithm detects negative weight cycles?
ADijkstra
BPrim
CBellman-Ford
DKruskal
Show Answer & Explanation

Correct Answer: C — Bellman-Ford

Bellman-Ford algorithm can detect negative weight cycles in a graph.

Q12.
Floyd-Warshall algorithm finds:
ASingle source shortest path
BAll pairs shortest paths
CMST
DTopological order
Show Answer & Explanation

Correct Answer: B — All pairs shortest paths

Floyd-Warshall finds shortest paths between all pairs of vertices.

Q13.
Time complexity of Floyd-Warshall algorithm:
AO(V²)
BO(V³)
CO(V+E)
DO(VE)
Show Answer & Explanation

Correct Answer: B — O(V³)

Floyd-Warshall uses three nested loops, giving O(V³) complexity.

Q14.
A graph is bipartite if it contains no cycle of:
AEven length
BOdd length
CLength 3
DLength 4
Show Answer & Explanation

Correct Answer: B — Odd length

A graph is bipartite if and only if it contains no odd-length cycles.

Q15.
Strongly connected components are found using:
ABFS only
BKosaraju or Tarjan algorithm
CDijkstra
DPrim
Show Answer & Explanation

Correct Answer: B — Kosaraju or Tarjan algorithm

Kosaraju's and Tarjan's algorithms find strongly connected components in directed graphs.

Q16.
An articulation point in a graph is:
AHighest degree vertex
BVertex whose removal disconnects graph
CLeaf node
DRoot node
Show Answer & Explanation

Correct Answer: B — Vertex whose removal disconnects graph

An articulation point (cut vertex) is a vertex whose removal increases connected components.

Q17.
In-degree of a vertex in directed graph is:
AOutgoing edges count
BIncoming edges count
CTotal edges
DSelf-loops
Show Answer & Explanation

Correct Answer: B — Incoming edges count

In-degree is the number of edges coming into a vertex.

Q18.
Which data structure is used in Dijkstra for efficiency?
AStack
BQueue
CMin-Heap/Priority Queue
DLinked List
Show Answer & Explanation

Correct Answer: C — Min-Heap/Priority Queue

Min-heap or priority queue gives O((V+E)log V) complexity for Dijkstra.

Q19.
A tree with n vertices has exactly:
An edges
Bn-1 edges
Cn+1 edges
D2n edges
Show Answer & Explanation

Correct Answer: B — n-1 edges

A tree is a connected acyclic graph with exactly n-1 edges for n vertices.

Q20.
Back edge in DFS indicates:
ATree structure
BPresence of cycle
CShortest path
DDisconnected graph
Show Answer & Explanation

Correct Answer: B — Presence of cycle

A back edge (edge to ancestor) in DFS tree indicates a cycle in the graph.