Q: 1 What is the chromatic number of the graph shown below?

3
4
5
6
[ 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 |
P–(ii), Q–(iii), R–(i)
P–(i), Q–(iii), R–(ii)
P–(ii), Q–(i), R–(iii)
P–(i), Q–(ii), R–(iii)
[ 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: 3 If 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
19
20
21
22
[ 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: 4 Spanning tree of a graph with V vertices has—
V Edges
V+1 Edges
V+2 Edges
V-1 Edges
[ 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: 5 Consider 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?
D(r,u) < d(r,v)
D (r,u) > d(r,v)
D(r,u) <=d(r,v)
None of the above
[ Option C ]
Q: 6 A graph is a collection of nodes called ________ and line segments called _______ that connect pairs of nodes.
Vertices, Paths
Vertices, Edges
Paths, Edges
Vertices, Vertices
[ 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: 7 A simple graph has
Both parallel edges and self-loops
Self-loops but not parallel edge
Parallel edges but no self-loop
Neither parallel edge nor self-loop
[ 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: 8 Which of the following is true for adjacency matrix representation of a graph with n vertices?
Space complexity is O(n)
Can not be used for directed graph
Space complexity is O(n2)
Can not be used for weighted graphs
[ 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: 9 What are the appropriate data structures for graph traversal using Breadth First Search (BFS) and Depth First Search (DFS) algorithms?
Stack for BFS and Queue for DFS
Queue for BFS and Stack for DFS
Stack for BFS and Stack for DFS
Queue for BFS and Queue for DFS
[ 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: 10 Consider 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
O(n), O(n2)
O(e), O(n2)
O(n2), O(e+n)
O(n+e), O(e)
[ 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: 11 For an undirected graph with n vertices and e edges, the sum of the degree of each vertex is:
2n
(2n-1)/2
2e
e2/2
[ 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.
Q: 12 If V is an isolated vertex in a graph, then the degree of V is:
0
1
2
5
[ Option A ]
An Isolated Vertex in a graph is a vertex that has no edges connected to it. The degree of a vertex is defined as the number of edges connected to that vertex. Since an isolated vertex has no connecting edges, its degree is 0.
Q: 13 There are 20 shopping malls in a city interconnected by roads. Each shopping mall can be reached through 3 different roads. It is assumed that
What is the maximum number of parks that can be constructed in the regions enclosed by roads?
12
30
60
11
[ Option D ]
In graph theory, when a network of roads and intersections is drawn on a plane without crossing edges, it forms a planar graph. For planar graphs, the relationship between the number of vertices (V), edges (E), and regions or faces (F) is given by Euler’s Formula: V-E+F=2
Here, faces (regions) represent the areas enclosed by the roads.
There are 20 shopping malls, so V=20. Each mall is connected by 3 roads, so the total number of edges is:
E=(20*3)/2 = 30
Because, each road connects two malls, so we divide by 2.
Using Euler’s formula:
20-30+F=2
F=12
These 12 regions include one outer region. Since parks can only be built in enclosed regions, the outer region is excluded.
Maximum number of parks = 12-1 = 11
Q: 14 Which of the following is not true about a complete graph with n vertices?
Each vertex has degree n-1
It contains no cycle
It is connected
It has n(n-1)/2 edges
[ Option B ]
In graph theory, a Complete Graph is a simple graph in which every pair of distinct vertices is connected by an edge.
Q: 15 An undirected graph G with ‘n’ vertices and ‘e’ edges is represented by an adjacency list. What is the time required to determine the total number of edges in the graph G?
O(e)
O(e2)
O(n)
O(n+e)
[ Option D ]
In an Adjacency List representation of an undirected graph, each vertex stores a list of its adjacent vertices.
To determine the total number of edges, we need to traverse all vertices, which takes O(n) time, and also traverse all adjacency lists, which takes O(e) time. Therefore, the total time required is O(n+e).
Q: 16 Number of vertices of odd degree in a graph is:
Always Even
Always Odd
Either Even or Odd
Always Zero
[ Option A ]
In any graph, the sum of the degrees of all vertices is always even because each edge contributes 2 to the total degree count. As a result, vertices with odd degree must occur in pairs so that their total contribution is even.
Q: 17 The number of edges in a regular graph of degree d and n vertices is—
nd/2
Maximum of n and d
nd
n+d
[ Option A ]
In a Regular Graph, every vertex has the same degree d, meaning each of the n vertices is connected to d edges. If we add the degrees of all vertices, the total becomes n*d.
However, each edge is counted twice in this total. Therefore, to get the actual number of edges, we divide by 2.
Hence, the number of edges in a regular graph with n vertices and degree d is nd/2.
Q: 18 Which of the following is NOT a graph traversal algorithm?
Greedy
Divide and Conquer
Dynamic Programming
None of the above
[ Option D ]
Graph traversal algorithms are specifically methods used to visit all nodes of a graph, such as:
Q: 19 Study the following statements:
Statements:
I- A cycle is an open walk with no repeated vertex.
II- A circuit is a closed walk with no repeated edge.
Which of the following is correct?
Only Statement I is true.
Only Statement II is true.
Both Statement I and II are true.
Neither Statement I nor II is true.
[ Option B ]
A Walk in a graph is a sequence of vertices and edges where each edge connects the previous vertex to the next one. It can repeat vertices or edges, there is no restriction.
In graph theory, a Cycle is a closed walk, meaning it starts and ends at the same vertex, and no other vertices or edges are repeated except the first and last vertex being the same.
A Circuit is indeed a closed walk (starts and ends at the same vertex) where no edge is repeated. Vertices may repeat, but edges do not.
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.