Algorithm_2k22_23_24
Algorithm_2k22_23_24
ii) In a multiset, elements are arranged in an unordered manner, with elements having a
multiplicity of
Answer: b) More than one
Explanation: A multiset allows duplicate elements, with multiplicity indicating their count.
vii) What is the time complexity of Kruskal's algorithm (E is the number of edges and V is the
number of vertices of input graph)?
Answer: b) O(E log V)
Explanation: Kruskal's algorithm sorts edges and uses union-find, leading to this complexity.
xii) What is the maximum number of swaps that can be performed in the Selection Sort
algorithm?
Answer: a) n-1
Explanation: Selection sort swaps once per pass, totaling n−1 swaps.
xv) If the array is already sorted, which of these algorithms will exhibit the best performance?
Answer: b) Insertion Sort
Explanation: Insertion sort runs in O(n) for already sorted arrays.
xvi) What is the maximum number of swaps that can be performed in the Bubble Sort
algorithm?
Answer: d) n(n-1)/2
Explanation: Bubble sort swaps every pair in the worst case, leading to this many swaps.
xxiv) Which of the following algorithms are used to find the shortest path from a source node
to all other nodes in a weighted graph?
Answer: b) Dijkstra's Algorithm
Explanation: Dijkstra's algorithm efficiently finds shortest paths in weighted graphs.
2024
i) LIFO scheme is used in data structure.
Answer: a) stack
Explanation: LIFO (Last In, First Out) is the principle used in stacks, where the last
element inserted is the first to be removed.
ii) Which of the following sorting algorithms has a worst-case time complexity of O(n log n)?
Answer: b) Merge sort
Explanation: Merge sort has O(n log n) worst-case time complexity due to its divide-and-conquer
approach.
v) Which of the following algorithm design techniques is used in the Merge sort algorithm?
Answer: c) Divide and conquer
Explanation: Merge sort divides the problem into smaller subproblems and conquers them
recursively.
vi) Which of the following is false in the case of a spanning tree of a graph G?
Answer: d) It can be either cyclic or acyclic
Explanation: A spanning tree is always acyclic by definition.
xiii) A binary tree is balanced if the difference of height between left and right sub-tree is not
more than
Answer: b) 1
Explanation: A balanced binary tree maintains a height difference of at most 1 between the left and
right subtrees.
xiv) The following numbers are inserted into an empty binary search tree in the given order:
10, 1, 3, 5, 15, 12, 16. What is the number of leaf nodes of the binary search tree?
Answer: b) 4
Explanation: After inserting the numbers, the leaf nodes are the nodes with no children, and there
are 4 leaf nodes.