You can prepare effectively for Software Development DSA in C++ with this dedicated MCQ Practice Test (available with solutions) on the important topic of "Test: Time and Space Complexity - 1". These 15 questions have been designed by the experts with the latest curriculum of Software Development 2026, to help you master the concept.
Test Highlights:
Sign up on EduRev for free to attempt this test and track your preparation progress.
Which of the following best describes time complexity in algorithms?
Detailed Solution: Question 1
Detailed Solution: Question 2
Which of the following represents the best-case time complexity of an algorithm? a) O
Detailed Solution: Question 3
Which of the following represents the worst-case time complexity of an algorithm?
Detailed Solution: Question 4
What does space complexity in algorithms measure?
Detailed Solution: Question 5
What is the time complexity of the following code snippet?
int sum = 0;
for (int i = 0; i < n; i++) {
sum += i;
}
Detailed Solution: Question 6
What is the output of the following code snippet?
int count = 0;
for (int i = 1; i <= n; i *= 2) {
count++;
}
cout << count;
Detailed Solution: Question 7
What is the time complexity of the following code snippet?
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cout << i << " " << j << endl;
}
}
Detailed Solution: Question 8
What is the output of the following code snippet?
int n = 5;
int count = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
for (int k = 1; k <= n; k++) {
count++;
}
}
}
cout << count;
Detailed Solution: Question 9
What is the space complexity of the following code snippet?
int n = 10;
int* arr = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = i;
}
delete[] arr;
Detailed Solution: Question 10
What is the time complexity of the following code snippet?
int count = 0;
for (int i = 1; i <= n; i *= 2) {
for (int j = 0; j < n; j++) {
count++;
}
}
cout << count;
Detailed Solution: Question 11
What is the time complexity of the following code snippet?
int count = 0;
for (int i = 1; i <= n; i *= 2) {
for (int j = 0; j < i; j++) {
count++;
}
}
cout << count;
Detailed Solution: Question 12
What is the time complexity of the following code snippet?
int count = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= i; j *= 2) {
count++;
}
}
cout << count;
Detailed Solution: Question 13
What is the time complexity of the following code snippet?
int count = 0;
for (int i = 1; i <= n; i *= 2) {
for (int j = 1; j <= i; j++) {
for (int k = 1; k <= n; k *= 2) {
count++;
}
}
}
cout << count;
Detailed Solution: Question 14
What is the time complexity of the following code snippet?
int count = 0;
for (int i = 0; i < n; i++) {
for (int j = i; j < n; j++) {
count++;
}
}
cout << count;
Detailed Solution: Question 15
152 videos|118 docs|24 tests |