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: 1Which of the following is NOT a step in the Divide and Conquer algorithm?
Option D
A Divide and Conquer algorithm are a problem-solving technique where a big problem is broken into smaller ones, solved individually, and then combined to produce the final answer. This method is used in algorithms like Merge Sort, Quick Sort, and Binary Search. The Divide and Conquer approach follow three main steps:
Q: 2Which of the following best describes memorization in dynamic programming?
Option A
Memorization is a key technique used in dynamic programming to improve efficiency by:
In other word, instead of recalculating the result every time, we "memorize" (store) it — typically using an array, map, or hash table.
Q: 3
Match the following:
| Encoding Type | Application |
|---|---|
| a. Binary Encoding | i. T.S.P. Scheduling |
| b. Permutation Encoding | ii. Engineering Design |
| c. Value Encoding | iii. Knapsack Problem |
| d. Tree Encoding | iv. Generic Programming |
Option A
In Genetic Algorithms (GA), encoding represents a possible solution in the form of a Chromosome. Different problems require different encoding methods depending on the structure of the solution.
Binary Encoding : Knapsack Problem
Binary encoding uses 0 and 1. In the Knapsack Problem, 1 can represent selecting an item and 0 can represent not selecting it.
Permutation Encoding : T.S.P. Scheduling
Permutation encoding represents a solution as an ordered sequence. It is suitable for TSP (Travelling Salesman Problem) because the order in which cities are visited is important.
Value Encoding : Generic Programming
Value encoding represents solutions using actual values, such as numbers or other problem-specific values. It is suitable for generic programming applications.
Tree Encoding : Engineering Design
Tree encoding represents a solution using a tree structure, making it suitable for problems involving hierarchical or structural designs, such as engineering design.
Q: 4Which of the following algorithm(s) use the Greedy Strategy?
(a) Bellman-Ford Algorithm
(b) Kruskal’s Algorithm
(c) Huffman Coding
(d) Dijkstra’s Algorithm
Option D
The Greedy Strategy solves a problem by making the best possible choice at each step, with the expectation that these locally optimal choices will lead to a globally optimal solution.
| Algorithm | Greedy Strategy? | Explanation |
|---|---|---|
| Bellman-Ford | No | It repeatedly relaxes all edges and can handle negative edge weights. It is not based on the greedy strategy. |
| Kruskal's Algorithm | Yes | It repeatedly selects the minimum-weight edge that does not create a cycle to construct the Minimum Spanning Tree (MST). |
| Huffman Coding | Yes | It repeatedly selects the two nodes with the lowest frequencies and combines them. This process continues until the Huffman tree is constructed. |
| Dijkstra's Algorithm | Yes | It repeatedly selects the unvisited vertex with the smallest tentative distance and finalizes its shortest distance. |
Bellman-Ford Algorithm is based on the Dynamic Programming approach, specifically repeated edge relaxation, rather than the Greedy strategy.
The actual use of Huffman Coding is data compression (Lossless Compression) (ZIP, JPEG, PNG). It reduces the number of bits required to represent data, especially when some characters/symbols occur much more frequently than others.
The two important greedy algorithms used for Minimum Spanning Tree are Kruskal's Algorithm and Prim's Algorithm.
Q: 5Which of the following is true about Greedy algorithm?
Option B
A Greedy Algorithm is a problem-solving technique in which the algorithm makes the best possible choice at the current step, without considering future consequences.
The main idea is to select the locally optimal solution at each stage with the hope that these choices will lead to a globally optimal solution.
Instead of exploring all possible solutions, the greedy approach selects the best immediate option according to a specific criterion such as minimum cost, maximum profit, or shortest distance.
This behavior distinguishes greedy algorithms from Dynamic Programming and Backtracking.
Q: 6
Match List-I (Solution Approach) with List-II (Problems) and select the correct answer:
| List-I | List-II |
|---|---|
| A. Divide and Conquer Approach | 1. Graph Coloring |
| B. Dynamic Programming | 2. 0/1 Knapsack |
| C. Greedy Approach | 3. Strassen Matrix Multiplication |
| D. Backtracking | 4. Huffman Encoding |
Option C
The Divide and Conquer Approach solves problems by dividing them into smaller independent subproblems and combining their solutions, which is exactly how Strassen Matrix Multiplication reduces matrix multiplication complexity.
Strassen’s Algorithm divides matrices into smaller sub-matrices, solves them recursively, and then combines the results.
Dynamic Programming is used when a problem has overlapping subproblems and optimal substructure. Dynamic programming stores intermediate results to avoid repeated computation. The 0/1 Knapsack problem has overlapping subproblems and optimal substructure.
The Greedy Approach works by making locally optimal choices, and Huffman Encoding uses this idea by repeatedly choosing the least frequent symbols to build an optimal coding tree.
The Backtracking is used to explore all possible solutions by trying choices and undoing them if they lead to failure. Graph Coloring tries different color assignments and backtracks whenever a conflict occurs, making backtracking the suitable approach.
Q: 7The knapsack problem where the objective function is to minimize the profit is-
Option D
The 0/1 Knapsack problem is a classic combinatorial optimization problem where each item must be either included or excluded from the knapsack. In this version, the objective is to minimize the profit (or cost), rather than maximize it. Simple greedy methods are not suitable here because they do not always guarantee an optimal solution for 0/1 decisions.
To handle minimization effectively, the Branch & Bound (0/1) technique is used. This method systematically explores all possible combinations of items while using bounds to prune suboptimal branches, which reduces unnecessary computations. While dynamic programming or backtracking can also solve the problem.
You have reached the end of this topic. Continue learning with the next topic below.
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.