This section contains carefully selected MCQs and Previous Year Questions with explanations to help students understand concepts and prepare effectively for examinations, interviews, and competitive tests.
Q: 1What is the chromatic number of the graph shown below?

Option B
The chromatic number of a graph is the minimum number of colors required to color the vertices so that no two adjacent vertices have the same color.
In the given graph, vertices such as e, f, g, and h form a structure where each is connected in a way that three colors are not sufficient to avoid conflicts between adjacent vertices. When we attempt coloring with 3 colors, at least two adjacent vertices will end up with the same color.
However, using 4 colors, we can assign colors to all vertices so that no adjacent vertices share the same color. Therefore, the minimum number of colors required is 4.
Q: 2
Match the following table showing algorithm and its application.
| Application | Algorithm |
|---|---|
| (P) A person wants to visit from one place to another place in shortest period | (i) Floyd’s algorithm |
| (Q) A person wants to visit M places in shortest period | (ii) Multi-stage graph algorithm |
| (R) All N persons want to visit all M places in shortest | (iii) Dijkstra’s algorithm |
Option A
Different Shortest-Path Algorithms are designed for different types of path problems in graphs. The key is to identify how many sources and destinations are involved and what type of path computation is required.
(P) A person wants to visit from one place to another place in the shortest period.
A Multi-Stage Graph Algorithm divides the graph into stages and computes the shortest path from the source to the destination using dynamic programming. It is commonly used when the movement must follow a stage-wise structure.
(Q) A person wants to visit M places in shortest period.
Dijkstra’s Algorithm computes the shortest path from a single source vertex to all other vertices in a weighted graph with non-negative edges.
(R) All N persons want to visit all M places in shortest.
Floyd’s Algorithm computes the shortest paths between every pair of vertices in a graph using dynamic programming and an adjacency matrix.
| ALGORITHM | DESCRIPTION | APPLICATION |
|---|---|---|
| Dijkstra’s Algorithm | Greedy Algorithm used to compute shortest path from a single source to all other vertices in a weighted graph. Uses Priority Queue. Works only when edge weights are non-negative. Faster than Bellman–Ford but cannot handle Negative Edges. | GPS navigation. Routing protocols. Shortest path in road networks. |
| Floyd–Warshall Algorithm | Dynamic Programming algorithm used to compute shortest paths between every pair of vertices (All-Pairs Shortest Path). Uses adjacency matrix and considers intermediate vertices one by one. Works even with negative weights but not negative cycles. | Network routing tables. Computing distances between all cities. |
| Bellman–Ford Algorithm | Computes single-source shortest paths by repeatedly relaxing all edges V-1 times. Can detect negative weight cycles. Slower than Dijkstra but more general because it supports Negative Edges. | Currency exchange systems. Networks with negative cost edges. |
| Multi-Stage Graph Algorithm | Uses Dynamic Programming for graphs divided into multiple stages. Computes shortest path from source to destination through sequential stages. Each stage only connects to the next stage. | Production scheduling. Pipeline processing. Stage-based decision problems. |
| Prim’s Algorithm | Greedy Algorithm that constructs a Minimum Spanning Tree (MST) by expanding a tree from a starting vertex and always selecting the smallest edge connecting the tree to a new vertex. | Designing communication networks. Power grids. |
| Kruskal’s Algorithm | Greedy Algorithm that builds Minimum Spanning Tree (MST) by sorting edges in increasing order and adding them if they do not form a cycle. Uses Disjoint Set (Union–Find) for cycle detection. | Road construction planning. Network cable layout. |
| Warshall’s Algorithm | Computes transitive closure of a graph using adjacency matrix. Determines whether a path exists between every pair of vertices (reachability problem). | Database query optimization. Dependency analysis. |
| Breadth First Search (BFS) | Graph Traversal technique that explores vertices level by level using a queue. Guarantees shortest path in unweighted graphs. | Social network analysis. Shortest path in unweighted graphs. |
| Depth First Search (DFS) | Traversal method that explores vertices deeply before backtracking using stack. Useful for cycle detection, connected components, topological sorting. | Compiler design. Maze solving. Graph connectivity. |
Q: 3The maximum number of edges in a ‘n’ node undirected graph without self—loop is
Option B
In an undirected graph with n nodes and no self‑loops, the maximum number of edges occurs when every pair of distinct nodes is connected by exactly one edge. That is, the graph is a Complete Graph Kn.
Q: 4If a graph has 31 edges and each vertex of the graph has degree atleast 3, then maximum number of possible vertices in the graph is
Option B
We use the Handshaking Theorem, which states that the sum of the degrees of all vertices in an undirected graph equals twice the number of edges:
Sum of degrees of all vertices=2×Number of edges
Here, E=31. So,
Sum of degrees = Sum of degrees=2×31=62
The given condition is that each vertex has degree at least 3. Now, let the number of vertices be n. Then, Sum of degrees ≥ 3n. We already know the exact sum is 62, so, 3n ≤ 62.
Finally solve for n, n ≤ 62/3 = 20.66. Since the number of vertices must be an integer, the maximum possible number of vertices is 20.
Q: 5Which of the following is correct?
Option A
A tree is a special type of graph that is connected and acyclic. This means all nodes are reachable from each other, and there is exactly one unique path between any two nodes.
Q: 6Spanning tree of a graph with V vertices has—
Option D
A Spanning Tree of a graph is a subgraph that includes all the vertices of the graph and is connected without forming any cycles. For any connected graph with V vertices, a tree structure must have exactly V-1 edges to remain connected and acyclic.
Q: 7Consider an undirected un-weighted graph G. Let a breadth first traversal of G be done starting from a node r. let d(r,u) and d(r,v) be the length of the shortest path from r to u and v respectively in G. if u is visited before v during the breadth first traversal, which of the following statement is correct?
Option C
Q: 8A graph is a collection of nodes called ________ and line segments called _______ that connect pairs of nodes.
Option B
In graph theory, a graph is made up of a set of nodes, which are technically called vertices, and a set of line segments that connect pairs of these nodes, which are called edges.
Vertices represent the objects or points in the graph, while edges represent the connections or relationships between them.
Q: 9A simple graph has
Option D
A Simple Graph is a type of graph that does not contain any parallel edges (multiple edges) or self-loops (an edge from a vertex to itself). Each edge in a simple graph connects two distinct vertices, and there can be at most one edge between any pair of vertices.
Q: 10Consider the following graph.

What is the weight of minimum spanning tree?
Option B
A Minimum Spanning Tree (MST) is a tree formed from a connected weighted graph such that:
In a graph having n vertices, the Minimum Spanning Tree always contains (n-1) edges.
The given graph contains the following weighted edges:
| Edge | Weight |
|---|---|
| P—Q | 30 |
| P—S | 40 |
| Q—R | 5 |
| Q—S | 20 |
| Q—T | 15 |
| S—T | 10 |
| R—T | 25 |
To construct the Minimum Spanning Tree, we select edges with the smallest weights while avoiding cycles.
Step 1:
Step 2:
Step 3:
Now vertices Q, R, S, T become connected without forming a cycle.
Step 4:
Now all vertices are connected and the spanning tree is complete.
Selected Edges:
| Selected Edge | Weight |
|---|---|
| Q—R | 5 |
| S—T | 10 |
| Q—T | 15 |
| P—Q | 30 |
Total Weight of MST : 5+10+15+30 = 60
Thus, the total weight of the Minimum Spanning Tree is 60.
Q: 11Which of the following is true for adjacency matrix representation of a graph with n vertices?
Option C
In an adjacency matrix, we represent a graph using a two-dimensional array of size n×n, where n is the number of vertices. Each row and column correspond to a vertex, and the value stored in a cell tells us whether an edge exists between two vertices.
If the graph is weighted, the cell stores the weight instead of just 0 or 1. Since the matrix always needs space for n2 entries, the space complexity is O(n2). This representation can be used for directed or undirected graphs as well as weighted or unweighted graphs.
The only drawback is that it uses more memory for sparse graphs, but it provides quick access to check if an edge exists between two vertices.
Q: 12What are the appropriate data structures for graph traversal using Breadth First Search (BFS) and Depth First Search (DFS) algorithms?
Option B
Breadth First Search (BFS) explores a graph level by level, meaning it visits all the neighboring vertices of a node before moving to the next level. To achieve this order, BFS uses a Queue, which follows the First In First Out (FIFO) principle.
Depth First Search (DFS), on the other hand, explores a graph by going as deep as possible along one path before backtracking. This behavior is naturally supported by a Stack, which follows the Last In First Out (LIFO) principle.
Q: 13Consider an undirected graph G with ‘n’ vertices and ‘e’ edges. What is the time taken by Depth First Search if G is represented by
i) Adjacency Matrix
ii) Adjacency List
Option C
Depth First Search (DFS) is a graph traversal algorithm that visits all vertices and edges of a graph.
The time complexity of DFS depends on how the graph is represented:
Adjacency Matrix:
In an adjacency matrix, we use an n×n matrix to represent edges. For each vertex, we must check all n possible vertices to see if an edge exists.
For n vertices, we check n entries for each vertex, so the total time complexity becomes O(n2).
Adjacency List:
In an adjacency list, each vertex stores only its connected neighbors, so during DFS each vertex is visited once taking O(n) time and each edge is traversed once taking O(e) time, resulting in a total time complexity of O(n+e).
| REPRESENTATION | STRUCTURE | DFS TIME | DFS TIME |
|---|---|---|---|
| Adjacency Matrix | 2D array | O(n2) | O(n2) |
| Adjacency List | Linked List | O(n+e) | O(n+e) |
Q: 14Which of the following is true about Dijkstra’s Algorithm?
Option B
Dijkstra’s Algorithm is a greedy algorithm used in graph theory to find the shortest path from a source node to all other nodes in a graph with non-negative edge weights. It works by repeatedly selecting the node with the minimum distance and updating the distances of its neighboring nodes.
Q: 15For an undirected graph with n vertices and e edges, the sum of the degree of each vertex is:
Option C
In an undirected graph, each edge connects two vertices and contributes 1 degree to each of its end vertices. Therefore, every edge adds a total of 2 to the sum of degrees of all vertices.
If the graph has e edges, the total sum of the degrees of all n vertices becomes 2e. This result is known as the Handshaking Theorem in graph theory.
Thank you so much for taking the time to read my Computer Science MCQs section carefully. Your support and interest mean a lot, and I truly appreciate you being part of this journey. Stay connected for more insights and updates! If you'd like to explore more tutorials and insights, check out my YouTube channel.
Don’t forget to subscribe and stay connected for future updates.