Explore topic-wise MCQs in Data Structures and Algorithms.

This section includes 85 Mcqs, each offering curated multiple-choice questions to sharpen your Data Structures and Algorithms knowledge and support exam preparation. Choose a topic below to get started.

51.

What is the average case time complexity of recursive selection sort?

A. O(n)
B. O(n log n)
C. O(n2)
D. O(log n)
Answer» D. O(log n)
52.

What is the time complexity of the above iterative implementation used to find the largest and smallest element in an array?

A. O(1)
B. O(n)
C. O(n2)
D. None of the mentioned
Answer» C. O(n2)
53.

What is the time complexity of the above iterative code used to find the smallest and largest element in a linked list?

A. O(1)
B. O(n)
C. O(n2)
D. O(n3)
Answer» C. O(n2)
54.

What is the time complexity of the above recursive implementation used to find the largest and the smallest element in an array?

A. O(1)
B. O(n)
C. O(n2)
D. O(n3)
Answer» C. O(n2)
55.

What is the time complexity of the recursive implementation used to find the largest and smallest element in a linked list?

A. O(1)
B. O(n)
C. O(n2)
D. O(n3)
Answer» C. O(n2)
56.

What is the number of swaps required to sort the array arr={5,3,2,4,1} using recursive selection sort?

A. 0
B. 1
C. 2
D. 3
Answer» D. 3
57.

Which of the following methods can be used to find the largest and smallest number in a linked list?

A. Recursion
B. Iteration
C. Both Recursion and iteration
D. None of the mentioned
Answer» D. None of the mentioned
58.

Which of the following methods can be used to find the largest and smallest element in an array?

A. Recursion
B. Iteration
C. Both recursion and iteration
D. None of the mentioned
Answer» D. None of the mentioned
59.

What is the time complexity of the above recursive implementation used to find the length of the string?

A. O(1)
B. O(n)
C. O(n2)
D. O(n3)
Answer» C. O(n2)
60.

Stack can be reversed without using extra space by _____________

A. using recursion
B. using linked list to implement stack
C. using an extra stack
D. it is not possible
Answer» C. using an extra stack
61.

Which of the following statement is true about stack?

A. Pop operation removes the top most element
B. Pop operation removes the bottom most element
C. Push operation adds new element at the bottom
D. Push operation removes the top most element
Answer» B. Pop operation removes the bottom most element
62.

What is the time complexity of matrix multiplied recursively by Divide and Conquer Method?

A. O(n)
B. O(n2)
C. O(n3)
D. O(n!)
Answer» D. O(n!)
63.

How many elements will be there in a matrix A*B multiplied recursively.

A. 12
B. 15
C. 16
D. 20
Answer» C. 16
64.

What is the space complexity of program to reverse stack recursively?

A. O(1)
B. O(log n)
C. O(n)
D. O(n log n)
Answer» D. O(n log n)
65.

How many recursive calls are there in Recursive matrix multiplication through Simple Divide and Conquer Method?

A. 2
B. 6
C. 9
D. 8
Answer» E.
66.

How many times is the function recursive_get_len() called when the above code is executed?

A. 5
B. 6
C. 7
D. 8
Answer» D. 8
67.

What is the time complexity of the above recursive implementation used to reverse a string?

A. O(1)
B. O(n)
C. O(n2)
D. O(n3)
Answer» C. O(n2)
68.

If Matrix A is of order X*Y and Matrix B is of order M*N, then what is the order of the Matrix A*B given that Y=M?

A. Y*N
B. X*M
C. X*N
D. Y*M
Answer» D. Y*M
69.

What is the time complexity of the above recursive implementation to find the sum of digits of a number n?

A. O(n)
B. O(1)
C. O(len(n)), where len(n) is the number of digits in n
D. none of the mentioned
Answer» D. none of the mentioned
70.

What is the time complexity of the above iterative implementation used to find the length of a linked list?

A. O(1)
B. O(n)
C. O(n2)
D. O(logn)
Answer» C. O(n2)
71.

What is the time complexity of the above code used to find the length of a linked list?

A. O(1)
B. O(n)
C. O(n2)
D. O(n3)
Answer» C. O(n2)
72.

For which of the following cases will the reversal of a string be equal to the original string?

A. Palindromic strings
B. Strings of length 1
C. Empty String
D. All of the mentioned
Answer» E.
73.

Which of the following is the binary representation of 100?

A. 1010010
B. 1110000
C. 1100100
D. 1010101
Answer» D. 1010101
74.

What is the space complexity of the recursive implementation used to convert a decimal number to its binary equivalent?

A. O(1)
B. O(n)
C. O(n2)
D. O(logn)
Answer» E.
75.

What is the time complexity of the recursive implementation used to convert a decimal number to its binary equivalent?

A. O(1)
B. O(n)
C. O(n2)
D. O(logn)
Answer» E.
76.

Space complexity of recursive solution of tower of hanoi puzzle is ________

A. O(1)
B. O(n)
C. O(log n)
D. O(n log n)
Answer» C. O(log n)
77.

Minimum number of moves required to solve a tower of hanoi problem with n disks is __________

A. 2n
B. 2n-1
C. n2
D. n2-1
Answer» C. n2
78.

Recurrence equation formed for the tower of hanoi problem is given by _________

A. T(n) = 2T(n-1)+n
B. T(n) = 2T(n/2)+c
C. T(n) = 2T(n-1)+c
D. T(n) = 2T(n/2)+n
Answer» D. T(n) = 2T(n/2)+n
79.

Which of the following is NOT a rule of tower of hanoi puzzle?

A. No disk should be placed over a smaller disk
B. Disk can only be moved if it is the uppermost disk of the stack
C. No disk should be placed over a larger disk
D. Only one disk can be moved at a time
Answer» D. Only one disk can be moved at a time
80.

Tower of hanoi problem can be solved iteratively.

A. True
B. False
Answer» B. False
81.

Recursive approach to find power of a number is preferred over iterative approach.

A. True
B. False
Answer» C.
82.

What is the objective of tower of hanoi puzzle?

A. To move all disks to some other rod by following rules
B. To divide the disks equally among the three rods by following rules
C. To move all disks to some other rod in random order
D. To divide the disks equally among three rods in random order
Answer» B. To divide the disks equally among the three rods by following rules
83.

Recursive solution of tower of hanoi problem is an example of which of the following algorithm?

A. Dynamic programming
B. Backtracking
C. Greedy algorithm
D. Divide and conquer
Answer» E.
84.

Minimum time required to solve tower of hanoi puzzle with 4 disks assuming one move takes 2 seconds, will be __________

A. 15 seconds
B. 30 seconds
C. 16 seconds
D. 32 seconds
Answer» C. 16 seconds
85.

The time complexity of the solution tower of hanoi problem using recursion is _________

A. O(n2)
B. O(2n)
C. O(n log n)
D. O(n)
Answer» C. O(n log n)