Which of the following asymptotic notations represents the worst-case time complexity of an algorithm?
The time complexity of an algorithm is expressed as O(log n). This indicates that the algorithm has a ________ time complexity.
1 Crore+ students have signed up on EduRev. Have you? Download the App |
Which of the following asymptotic notations represents the upper bound of the time complexity of an algorithm?
In terms of time complexity, which of the following statements is correct?
The time complexity of an algorithm is given by T(n) = 5n^2 + 3n + 2. What is the dominant term in this equation?
What will be the output of the following code?
int sum = 0;
for (int i = 0; i < n; i++) {
for (int j = 1; j < n; j = j * 2) {
sum++;
}
}
cout << sum;
What will be the output of the following code?
int func(int n) {
if (n <= 0) {
return 1;
}
return func(n / 2) + func(n / 2);
}
int result = func(8);
cout << result;
What will be the output of the following code?
int n = 100;
int count = 0;
while (n > 0) {
n = n / 2;
count++;
}
cout << count;
What will be the output of the following code?
int n = 5;
for (int i = 1; i <= n; i++) {
for (int j = i; j <= n; j = j * 2) {
cout << j << " ";
}
cout << endl;
}
What will be the output of the following code?
int n = 4;
int count = 0;
for (int i = n; i >= 1; i = i / 2) {
for (int j = 1; j <= i; j++) {
count++;
}
}
cout << count;
What is the time complexity of the following code snippet?
int func(int n) {
if (n <= 0) {
return 0;
}
return 1 + func(n / 2);
}
int result = func(16);
What is the space complexity of the following code snippet?
void func(int n) {
if (n <= 0) {
return;
}
cout << n << " ";
func(n - 1);
func(n - 1);
}
func(4);
Which of the following statements about time complexity is false?
What is the time complexity of the following code snippet?
int sum = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j = j * 2) {
sum++;
}
}
What is the space complexity of the following code snippet?
int fib(int n) {
if (n <= 1) {
return n;
}
return fib(n - 1) + fib(n - 2);
}
int result = fib(5);
153 videos|115 docs|24 tests
|
153 videos|115 docs|24 tests
|