Explore topic-wise MCQs in Data Structures and Algorithms.

This section includes 15 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.

1.

Consider the following implementation of Kadane’s algorithm:

A. Only Change 1 is sufficient
B. Only Change 2 is sufficient
C. Both Change 1 and Change 2 are necessary
D. No change is requiredView Answer
Answer» D. No change is requiredView Answer
2.

What is the output of the following implementation of Kadane’s algorithm?

A. 6
B. 7
C. 8
D. 9View Answer
Answer» E.
3.

What is the space complexity of Kadane’s algorithm?

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

What is the time complexity of Kadane’s algorithm?

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

Complete the following code for Kadane’s algorithm:

A. max_num(sum, sum + arr[idx])
B. sum
C. sum + arr[idx]
D. max_num(sum,ans)View Answer
Answer» E.
6.

For which of the following inputs would Kadane’s algorithm produce a WRONG output?

A. {1,0,-1}
B. {-1,-2,-3}
C. {1,2,3}
D. {0,0,0}
Answer» C. {1,2,3}
7.

For which of the following inputs would Kadane’s algorithm produce the INCORRECT output?

A. {0,1,2,3}
B. {-1,0,1}
C. {-1,-2,-3,0}
D. {-4,-3,-2,-1}
Answer» E.
8.

Kadane’s algorithm uses which of the following techniques?

A. Divide and conquer
B. Dynamic programming
C. Recursion
D. Greedy algorithm
Answer» C. Recursion
9.

Kadane’s algorithm is used to find ____________

A. Longest increasing subsequence
B. Longest palindrome subsequence
C. Maximum sub-array sum
D. Longest decreasing subsequence
Answer» D. Longest decreasing subsequence
10.

6$

A. 7
B. 8
C. 9
Answer» D.
11.

What is the time complexity of Kadane’s algorithm?$

A. O(1)
B. O(n)
C. O(n<sup>2</sup>)
D. None of the mentioned
Answer» B. O(n)
12.

max_num(sum, sum + arr[idx])

A. sum
B. sum + arr[idx].
C. max_num(sum,ans)
Answer» C. max_num(sum,ans)
13.

For which of the following inputs would Kadane’s algorithm produce the CORRECT output?$

A. {0,1,2,3}
B. {-1,0,1}
C. {-1,-2,-3,0}
D. All of the mentioned
Answer» E.
14.

Kadane’s algorithm uses which of the following techniques?$

A. Divide and conquer
B. Dynamic programming
C. Recursion
D. All of the mentioned
Answer» C. Recursion
15.

Kadane’s algorithm is used to find ____________

A. Longest increasing subsequence
B. Longest palindrome subsequence
C. Maximum sub-array sum
D. All of the mentioned
Answer» D. All of the mentioned