adplus-dvertising

Welcome to the Algorithm Complexity MCQs Page

Dive deep into the fascinating world of Algorithm Complexity with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Algorithm Complexity, a crucial aspect of Data Structures and Algorithms. In this section, you will encounter a diverse range of MCQs that cover various aspects of Algorithm Complexity, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within Data Structures and Algorithms.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Algorithm Complexity. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of Data Structures and Algorithms.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Algorithm Complexity. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Algorithm Complexity MCQs | Page 8 of 10

Q71.
What is the time, space complexity of following code:
int a = 0, b = 0;
for (i = 0; i < N; i++) 
{
a = a + rand();
}
for (j = 0; j < M; j++) 
{
b = b + rand();
}
Discuss
Answer: (c).O(N + M) time, O(1) space
Q72.
What is the time complexity of following code:
int a = 0;
for (i = 0; i < N; i++) 
{
for (j = N; j > i; j--) 
{
a = a + i + j;
}
}
Discuss
Answer: (d).O(N*N)
Q73.
What is the time complexity of following code:
int i, j, k = 0;
for (i = n / 2; i <= n; i++) 
{
for (j = 2; j <= n; j = j * 2) 
{
k = k + n / 2;
}
}
Discuss
Answer: (b).O(nLogn)
Discuss
Answer: (b).Pivot is the smallest element
Discuss
Answer: (b).X will always be a better choice for large inputs
Q76.
The complexity of Fibonacci series is
Discuss
Answer: (a).O(2ⁿ)
Q77.
What is the time complexity of following code:
int a = 0, i = N;
while (i > 0) 
{
a += i;
i /= 2;
}
Discuss
Answer: (d).O(log N)
Q78.
The complexity of Binary search algorithm is
int a = 0, i = N;
while (i > 0) 
{
a += i;
i /= 2;
}
Discuss
Answer: (b).O(log n )
Q79.
The worst case complexity for insertion sort is
Discuss
Answer: (c).O(n²)
Q80.
The worst case complexity of quick sort is
Discuss
Answer: (c).O(n²)
Page 8 of 10

Suggested Topics

Are you eager to expand your knowledge beyond Data Structures and Algorithms? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!