Algorithms MCQ Quiz in मल्याळम - Objective Question with Answer for Algorithms - സൗജന്യ PDF ഡൗൺലോഡ് ചെയ്യുക
Last updated on Mar 9, 2025
Latest Algorithms MCQ Objective Questions
Top Algorithms MCQ Objective Questions
Algorithms Question 1:
All statements, except for the recursive calls F(n), have O(1) time complexity for the below given flow chart. If the worst-case time complexity of this function is O(nλ ), then the least possible (accurate up to one decimal position) of λ is _______.
Answer (Detailed Solution Below) 1.60 - 1.65
Algorithms Question 1 Detailed Solution
Answer: 1.6 to 1.65
Explanation:
The worst-case happens for the recursive calls on the longer route.
There are 6 such recursive calls to A(n/3) in the worst case.
So, recurrence relation will become like this:
F (n) = 6F(n/3) + O(1)
where O(1) is constant
By using master’s theorem,
a = 6, b =3
λ = 1.63
Algorithms Question 2:
Consider the following undirected graph with edge weights as shown:
The number of minimum-weight spanning trees of the graph is ______
Answer (Detailed Solution Below) 3
Algorithms Question 2 Detailed Solution
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.
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.
Algorithms Question 3:
Consider the following C function.
int fun(int n) {
int i, j;
for (i = 1; i
for (j = 1; j
printf (‘’ %d %d’’, i, j);
}
}
}
Time complexity of fun in terms of Θ notation is
Answer (Detailed Solution Below)
Algorithms Question 3 Detailed Solution
We have to check how many times inner loop will be executed here.
For i=1,
j will run 1 + 2 + 3 + …………. (n times)
For i=2
j will run for 1,3,5, 7, 9, 11,………..(n/2 times)
For i=3
j will run for 1,4,7,10, 13…………… (n/3 times)
So, in this way,
So, Time complexity of given program = Θ (n log n)
Algorithms Question 4:
The k-Means algorithm is an ______ algorithm.
Answer (Detailed Solution Below)
Algorithms Question 4 Detailed Solution
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.
Algorithms Question 5:
Which Sorting method is an external Sort?
Answer (Detailed Solution Below)
Algorithms Question 5 Detailed Solution
Concept:
External sorting is sorting the lists that are so large that the whole list cannot be contained in the internal memory of a computer.
Explanation:
All heap sort, quick sort and insertion sort uses the concept of internal sorting. In internal sorting, data that has to be stored will be in main memory always and it implies faster access.
Important Point:
Example of external sorting is merge sort algorithm
External merge sort algorithm steps:
→ Data is stored in intermediate files
→ intermediate files are sorted and merged.
External sorting algorithms by external memory model in which a cache or internal memory is considered and an unbounded external memory is divided into blocks and time complexity is the number of memory transfers between internal and external memory.
Algorithms Question 6:
The maximum number of spanning tree possible for graph K5 is _____.
Answer (Detailed Solution Below)
Algorithms Question 6 Detailed Solution
Data:
K5 is a complete graph with 5 vertex, that is, n = 5
Formula:
maximum number of spanning tree possible = nn - 2
Calculation:
maximum number of spanning tree = 55-2 = 125
Algorithms Question 7:
Let f(n) = n and g(n) = n(1 + sin n), where n is a positive integer. Which of the following statements is/are correct?
I. f(n) = O(g(n))
II. f(n) = Ω(g(n))
Answer (Detailed Solution Below)
Algorithms Question 7 Detailed Solution
Concept:
Sin function value ranges from -1 to + 1. (-1, 0, 1)
Explanation:
Case 1: when sin(n) is -1,
g(n) = n(1 - 1) = n0 = 1
so, for this case f(n) > g(n) i.e. g(n) = O (f(n))
So, statement 1 is incorrect.
Case 2: when sin(n) is +1,
g(n) = n(1 + 1) = n2
so, for this case f(n)
but for this, second statement i.e. f(n) = Ω(g(n)) is incorrect.
Both statements are not true for all values of sin(n).
Hence, option 4 is correct answer.
Algorithms Question 8:
Let the length of sorted arrays of A1, A2, A3, A4, A5, and A6 be 41, 30, 15, 80, 25 and 50 respectively. To merge them into a single array A by merging two arrays at a time using optimal algorithm. In worst case, the maximum number of comparisons needed is _____.
Answer (Detailed Solution Below) 587
Algorithms Question 8 Detailed Solution
The optimal algorithm always selects the smallest sequences for merging.
Given sequence: 41, 30, 15, 80, 25, 50
Ascending order: 15, 25, 30, 41, 50, 80
Merge(15, 25) → new size (40)
Number of comparisons = 25 + 15 – 1 = 39
Merge(30, 40) → new size (70)
Number of comparisons = 30 + 40 – 1 = 69
Merge(41, 50) → new size (91)
Number of comparisons = 41 + 50 – 1 = 90
Merge(70, 80) → new size (150)
Number of comparisons = 70 + 80 – 1 = 149
Merge(91, 150) → new size (241)
Number of comparisons = 91 + 150 – 1 = 240
Therefore, total number of comparisons, 39 + 69 + 90 + 149 + 240 = 587
Algorithms Question 9:
Which one of the diagrams is used to start/stop in a flowchart?
Answer (Detailed Solution Below)
Algorithms Question 9 Detailed Solution
The correct answer is option 3.
Concept
- A flowchart is a diagrammatic representation that illustrates a solution model to a given problem. It is used to depict the process of an operation or task, from startups to completion. It's a useful tool for visualizing a process, which can help to better understand, analyze, or improve it.
Key Points
Symbol |
Diagram |
Function |
Parallelogram |
A parallelogram represents part of an input or output. |
|
Arrows |
A line is a connector that shows the relationship between the representative shape. |
|
Oval |
A oval represents start and endpoint. |
|
Diamond |
A diamond represents a decision. |
|
Rectangle |
A rectangle represents a Process. |
Algorithms Question 10:
What is the complexity of selection sort algorithms?
Answer (Detailed Solution Below)
Algorithms Question 10 Detailed Solution
The time complexity of selection sort = Number of swaps + number of comparisons.
= n swaps + n2 comparisons.
The time complexity of selection sort = O(n2).
Hence the correct answer is O(n2).
Additional Information
Algorithm | Time Complexity | ||
Best | Average | Worst | |
Selection Sort | (Ωn2) | θ(n2) | O(n2) |
Bubble Sort | Ω(n) | θ(n2) | O(n2) |
Insertion Sort | Ω(n) | θ(n2) | O(n2) |
Heap Sort | Ω(n log(n)) | θ(n log(n)) | O(n log(n)) |
Quick Sort | Ω(n log(n)) | θ(n log(n)) | O(n2) |
Merge Sort | Ω(n log(n)) | θ(n log(n)) | O(n log(n)) |
Bucket Sort | Ω(n+k) | θ(n+k) | O(n2) |
Radix Sort | Ω(nk) | θ(nk) | O(nk) |