Algorithms MCQ Quiz - Objective Question with Answer for Algorithms - Download Free PDF

Last updated on Jun 10, 2025

Algorithms are step-by-step procedures or methods for solving computational problems. They consist of a sequence of instructions or rules that describe how to perform a specific task or solve a particular problem. Algorithms MCQs cover topics such as algorithm design techniques (such as divide and conquer, greedy algorithms, and dynamic programming), algorithm analysis, data structures, sorting and searching algorithms, and algorithm complexity. These MCQs assess knowledge of algorithmic problem-solving, algorithm design principles, and computational efficiency. Check your knowledge about this mathematical and computation concept with Algorithm MCQs given here.

Latest Algorithms MCQ Objective Questions

Algorithms Question 1:

The weight of minimum spanning tree in graph G, calculated using Kruskal’s algorithm is:

F1 R.S 18.5.20 Pallavi D2

  1. 14
  2. 15
  3. 17
  4. 18
  5. None of the above

Answer (Detailed Solution Below)

Option 2 : 15

Algorithms Question 1 Detailed Solution

Concept:

A minimum spanning tree (MST) or minimum weight spanning tree is a subset of the edges(V – 1 ) of a connected, edge-weighted undirected graph G(V, E) that connects all the vertices together, without any cycles and with the minimum possible total edge weight.

Explanation:

Edge set for the given graph = {2, 3, 4, 5, 6, 7, 8}

For 5 vertices, we need 4 edges in MST,

So, edge set for MST = {2, 3, 4, 6}

Minimum spanning tree

F2 R.S 18.5.20 Pallavi D1

Minimum cost 2 + 3 + 4 + 6 = 15

Algorithms Question 2:

Consider the following Statements

Statement 1: Greedy technique solves the problem correctly and always provides an optimized solution to the problem.

Statement 2: Bellman ford, Floyd-warshal, and Prim’s algorithms use the Dynamic Programming technique to solve the Path problems.

Which of the following is true?

  1. Statement 1 is true only
  2. Statement 2 is false only
  3. Statement 1 and Statement 2 both are false.
  4. Statement 1 and Statement 2 both are true.
  5. None of the above

Answer (Detailed Solution Below)

Option 3 : Statement 1 and Statement 2 both are false.

Algorithms Question 2 Detailed Solution

Answer: Option 3

Explanation

Statement 1: Greedy technique solves the problem correctly and always provides an optimized solution to the problem.

This Statement is False. Since the Greedy technique does not always solve a problem correctly.

Statement 2: Bellman ford, Floyd-warshal, and Prim’s algorithms use the Dynamic Programming technique to solve the Path problems.

This Statement is also False Since Prim's algorithm does not use the Dynamic Programming technique.

Prim's algorithm is a greedy algorithm that finds a minimum spanning tree for a weighted undirected graph. 

Algorithms Question 3:

Time complexity of Merge Sort Algorithm and Binary Search Algorithm are respectively:

  1. O(log2 n) and O(n log2 n)
  2. O(n log2 n) and O(log2 n)
  3. O(n2) and O(log2 n)
  4. O(2n) and O(n2)
  5. None of the above

Answer (Detailed Solution Below)

Option 2 : O(n log2 n) and O(log2 n)

Algorithms Question 3 Detailed Solution

Merge sort 

It is based on the divide and conquers approach.

Recurrence relation for merge sort will become:

T(n) = 2T (n/2) + Θ (n)

Using Master’s theorem

T (n) = n × log2n

Therefore, the time complexity of Merge Sort is θ(nlogn).

Binary Search

Search a sorted array by repeatedly dividing the search interval in half.

Recurrence for binary search is T(n) = T(n/2) + θ(1)

Using Master’s theorem

T (n) = log2n

Consider only half of the input list and throw out the other half. Hence time complexity is O(log n).

Algorithms Question 4:

Which of the following algorithm design technique is used in designing quick sort algorithm

  1. Dynamic programming method
  2. Back tracking strategy
  3. Divide and conquer strategy
  4. Greedy strategy
  5. None of the above

Answer (Detailed Solution Below)

Option 3 : Divide and conquer strategy

Algorithms Question 4 Detailed Solution

Key Points
  • Quicksort is a divide-and-conquer algorithm in which the pivot element is chosen, and this pivot element reduced the given problem into two smaller sets.
  • Quick Sort is useful for sorting arrays.
  • Inefficient implementations Quick Sort is not a stable sort, meaning that the relative order of equal sort items is not preserved.
  • The overall time complexity of Quick Sort is O(nLogn). In the worst case, it makes O(n2) comparisons, though this behavior is rare.
  • The space complexity of Quick Sort is O(nLogn). It is an in-place sort (i.e. it doesn’t require any extra storage).

Hence the correct answer is Divide and conquers strategy.

Algorithms Question 5:

Which one of the following properties of an algorithm ensures that each step of the algorithm is properly defined and the actions to be performed are clearly specified?

  1. Finiteness
  2. Effectiveness
  3. Input and Output
  4. Definiteness
  5. None of the above

Answer (Detailed Solution Below)

Option 4 : Definiteness

Algorithms Question 5 Detailed Solution

Key Points

 Definiteness:

Each step must be precisely defined; the actions to be carried out must be rigorously and unambiguously specified for each case. input: An algorithm has zero or more inputs, taken from a specified set of objects. output: An algorithm has one or more outputs, which have a specified relation to the inputs.

Hence the correct answer is Definiteness.

Additional Information

Finiteness:

For any input, the algorithm must terminate after a finite number of steps. Definiteness: All steps of the algorithm must be precisely defined. Effectiveness: It must be possible to perform each step of the algorithm correctly and in a finite amount of time.

Effectiveness:

For an algorithm to be effective, it means that all those steps that are required to get to output must be feasible with the available resources. It should not contain any unnecessary and redundant steps which could make an algorithm ineffective.

input:

An algorithm has zero or more inputs, taken from a specified set of objects.

Output:

An algorithm has one or more outputs, which have a specified relation to the inputs.

Top Algorithms MCQ Objective Questions

A _________ is used to show the processing that takes place in the flowchart.

  1. Diamond
  2. Ellipse
  3. Arrows
  4. Rectangle

Answer (Detailed Solution Below)

Option 4 : Rectangle

Algorithms Question 6 Detailed Solution

Download Solution PDF

Concept:

Flowcharts use special shapes to represent different types of actions or steps in a process. Lines and arrows show the sequence of the steps, and the relationships among them. These are known as flowchart symbols.

fcsym

Hence Option 4 is correct

What is the time complexity for the following C module? Assume that n > 0;

int module(int n)

{

if(n == 1)

return 1;

else

return (n + module(n-1));

}

  1. O(n)
  2. O(log n)
  3. O(n2)
  4. O(n!)

Answer (Detailed Solution Below)

Option 1 : O(n)

Algorithms Question 7 Detailed Solution

Download Solution PDF

Answer: Option 1

Explanation

f(n) =  n + module(n-1);  / since return (n + module(n-1));

Here recurrence relation will be

T(n) = T(n-1) + c

≡ T(n-2) + c + c

≡ T(n-3) + 3c

≡ T(n-k) + kc

when n-k = 1 ; k = n-1 and T(1) = 1

≡ T(1) + (n-1)c

≡ (n-1)c

≡ O(n) 

Hence Option 1 is correct answer.

Here some of you might have cam up with recurrence relation T(n) = T(n-1) + n, which is incorrect because in function n is just a variable it will have a constant value which will get added to call return value and In recurrence variable n indicate cost.  

Consider the recurrence function \(T\left( n \right) = \left\{ {\begin{array}{*{20}{c}} {2T\left( {\sqrt n } \right) + 1,\;\;\;n > 2}\\ {2,\;\;\;0 < n \le 2} \end{array}} \right.\) Then T(n) in terms of Θ notation is

  1. Θ (log log n)
  2. Θ (log n)
  3. Θ (√n)
  4. Θ (n)

Answer (Detailed Solution Below)

Option 2 : Θ (log n)

Algorithms Question 8 Detailed Solution

Download Solution PDF

\(T\left( n \right) = 2\;T\left( {\sqrt n } \right) + 1\)

Put n= 2m, m = log2n

\(T\left( {{2^m}} \right) = 2T\left( {{2^{\frac{m}{2}}}} \right) + 1\)

\(Put\;T\left( {{2^m}} \right) = S\left( m \right)\)

\(S\left( m \right) = 2\;S\;\left( {\frac{m}{2}} \right) + 1\)

Now, calculate \({n^{log_b^a}}\)

\({m^{log_b^a}} = m\)

S (m) = m + 1

S(m) = m

Put the value of m 

Therefore, T(n) in terms of Θ notation is Θ (logn).

Which one of the following correctly determines the solution of the recurrence relation with

T(1) = 1?

\(T\left( n \right) = 2T\left( {\frac{n}{2}} \right) + \log n\)

  1. Θ(n)
  2. Θ(n log n)
  3. Θ (n2)
  4. Θ(log n)

Answer (Detailed Solution Below)

Option 1 : Θ(n)

Algorithms Question 9 Detailed Solution

Download Solution PDF

\({\rm{T}}\left( {\rm{n}} \right) = 2{\rm{T}}\left( {\frac{{\rm{n}}}{2}} \right) + \log {\rm{n}}\)

Comparing with:

\({\rm{T}}\left( {\rm{n}} \right) = {\rm{aT}}\left( {\frac{{\rm{n}}}{{\rm{b}}}} \right) + f\left( n \right)\)

a = 2, b = 2, f(n) = log n

\({n^{{{\log }_2}2}} = n\) > f(n)

By Master’s theorem

\(T\left( {\rm{n}} \right) = {\rm{O}}\left( {\rm{n}} \right)\)

Consider the following C function.

int fun1(int n) {

int i, j, k, p, q = 0;

for (i = 1; i n; ++i) {

p = 0;

for (j = n; j > 1; j = j/2)

 ++ p;

for (k = 1; k<p; k = k*2)

 ++ q;

}

return q;

}

Which one of the following most closely approximates the return value of the function fun1?

  1. n3
  2. n(log2)
  3. n log n
  4. n log (log n)

Answer (Detailed Solution Below)

Option 4 : n log (log n)

Algorithms Question 10 Detailed Solution

Download Solution PDF

zza17

\(\begin{array}{l} \therefore p\; = \;\log n,\;q\; = \;\log p\; = \;\log \left( {\log n} \right)\\ \therefore q\; = \;n.\log \left( {\log n} \right) \end{array}\)

In flowchart representation, which of the following symbols indicates input/output?

  1. Oval
  2. Parallelogram
  3. Diamond
  4. Rectangle

Answer (Detailed Solution Below)

Option 2 : Parallelogram

Algorithms Question 11 Detailed Solution

Download Solution PDF

Explanation:

  • An oval represents a start or end point
  • A line is a connector that shows relationships between the representative shapes
  • A parallelogram represents input and output
  • A rectangle represents a process
  • A diamond indicates a decision

 

The given symbol represents the predefined process such as a sub-routine or a module.

Design Element

Shape

Design Element

Shape

Design Element

Shape

Process

F1 Uday Madhu 02.07.20 D2

Sequential data

F1 Uday Madhu 02.07.20 D10

Parallel mode

F1 Uday Madhu 02.07.20 D18

Terminator

F1 Uday Madhu 02.07.20 D3

Direct data

F1 Uday Madhu 02.07.20 D11

Loop limit

F1 Uday Madhu 02.07.20 D19

Decision

F1 Uday Madhu 02.07.20 D4

Manual input

F1 Uday Madhu 02.07.20 D12

On-page reference

F1 Uday Madhu 02.07.20 D20

Document

F1 Uday Madhu 02.07.20 D5

Card

F1 Uday Madhu 02.07.20 D13

Off-page reference

F1 Uday Madhu 02.07.20 D21

Data (input and output)

F1 Uday Madhu 02.07.20 D6

Paper tape

F1 Uday Madhu 02.07.20 D14

Yes/No decision indicators

F1 Uday Madhu 02.07.20 D22

Predefined process (such as subroutine or a module)

F1 Uday Madhu 02.07.20 D7

Display

F1 Uday Madhu 02.07.20 D15

Condition

F1 Uday Madhu 02.07.20 D23

Stored data

F1 Uday Madhu 02.07.20 D8

Manual operation

F1 Uday Madhu 02.07.20 D16

Control transfer

F1 Uday Madhu 02.07.20 D24

Internal storage

F1 Uday Madhu 02.07.20 D9

Preparation

F1 Uday Madhu 02.07.20 D17

Annotation

F1 Uday Madhu 02.07.20 D25

Give asymptotic upper and lower bound for T(n) given below. Assume T(n) is constant for \(n \le 2.\;T\left( n \right) = 4T\left( {\sqrt n } \right) + lo{g^2}n\)

  1. T(n) = θ(lg(lg2n)lg n)
  2. T(n) = θ(lg2nlgn)
  3. T(n) = θ(lg2 n lg lg n)
  4. T(n) = θ(lg(lg n))g n) 

Answer (Detailed Solution Below)

Option 3 : T(n) = θ(lg2 n lg lg n)

Algorithms Question 12 Detailed Solution

Download Solution PDF

\(T\left( n \right) = 4T\left( {√ n } \right) + lo{g^2}n\)

Consider n = 2m

m = log2n

n = 2m

Taking square root

√n = 2m/2

T(2m) = 4T(2m/2) + m2

Put S(m) = T (2m/2)

S(m) = 4 S(m/2) + m2

Comparing with

T(m) = a T(m/k) + cmk

a = 4, b = 2, k = 2

a = bk = 4

Now use master’s theorem :

T(m) = O(mklog m)

So, Time complexity will be O(m2log m)

Put the value of m

Time complexity will be :  O (log2n log (logn))

Consider a hash table of size 7, with hash function H (k) = k % 7, and pseudo random i = (i + 5) % 7. We want to insert the following keys one by one from left to right.

15, 11, 25, 16, 9, 8, 12

What will be the position of the key 25, if we use random probing?

  1. 4
  2. 5
  3. 1
  4. 2

Answer (Detailed Solution Below)

Option 4 : 2

Algorithms Question 13 Detailed Solution

Download Solution PDF

Since we are using random probing:

Insert 15:

(15)%7 = 1

Insert 11:

(11)%7 = 4

Insert 25:

(25)%7 = 4 / collision:

i = 4

 i = (i + 5) % 7    / using random function

i = (4 + 5)%7 = 2

Hence 25 position is 2nd

The k-Means algorithm is an ______  algorithm.

  1. Supervised Learning
  2. Unsupervised Learning
  3. Semi-supervised Learning
  4. Reinforcement Learning

Answer (Detailed Solution Below)

Option 2 : Unsupervised Learning

Algorithms Question 14 Detailed Solution

Download Solution PDF

The correct answer is Unsupervised Learning.

Key Points 

1. Supervised Learning:

  • In supervised learning, the algorithm is trained on a labeled dataset, where the input data is paired with corresponding output labels.
  • The goal is to learn a mapping function from input to output so that the algorithm can make predictions or classifications on new, unseen data.

2. Unsupervised Learning:

  • In unsupervised learning, the algorithm is given data without explicit instructions on what to do with it.
  • The algorithm tries to find patterns, relationships, or structures within the data on its own.
  • Clustering algorithms, like k-Means, fall under unsupervised learning because they group similar data points together without using labeled output information.

3. Semi-supervised Learning:

  • Semi-supervised learning is a combination of supervised and unsupervised learning.
  • It involves a dataset that contains both labeled and unlabeled examples.
  • The algorithm is trained on the labeled data, and then it tries to make predictions on the unlabeled data by leveraging the patterns learned from the labeled data.

4. Reinforcement Learning:

  • Reinforcement learning involves an agent interacting with an environment and learning to make decisions by receiving feedback in the form of rewards or punishments.
  • The agent learns to take actions that maximize the cumulative reward over time.
  • Unlike supervised learning, where the algorithm is provided with explicit labeled examples, in reinforcement learning, the algorithm learns by trial and error.

In the case of the k-Means algorithm, it is unsupervised learning because it doesn't rely on labeled output data. Instead, it aims to partition the input data into clusters based on similarity, without using predefined class labels.

Consider the following undirected graph with edge weights as shown:

F2 Gaurav Mankar 31-3-2021 Swati D15
The number of minimum-weight spanning trees of the graph is ______

Answer (Detailed Solution Below) 3

Algorithms Question 15 Detailed Solution

Download Solution PDF

Answer:3 to 3

Concept:

A minimum spanning tree (MST) or minimum weight spanning tree is a subset of the edges(V – 1 ) of a connected, edge-weighted undirected graph G(V, E) that connects all the vertices together, without any cycles and with the minimum possible total edge weight.

Explanation:

The minimum weight in the graph is 0.1 choosing this we get.

F1 Raju.S 01-04-21 Savita D17

Suppose we get two trees T1 and T2.

To connect to those two trees we got 3 possible edges of weight 0.9.

Hence we can choose any one of those 3 edges.

No of Minimum weight spanning tree is 3.

Get Free Access Now
Hot Links: teen patti boss teen patti tiger teen patti gold download apk yono teen patti