Which of the following best describes time complexity in algorithms?
1 Crore+ students have signed up on EduRev. Have you? Download the App |
Which of the following represents the best-case time complexity of an algorithm? a) O
Which of the following represents the worst-case time complexity of an algorithm?
What does space complexity in algorithms measure?
What is the time complexity of the following code snippet?
int sum = 0;
for (int i = 0; i < n; i++) {
sum += i;
}
What is the output of the following code snippet?
int count = 0;
for (int i = 1; i <= n; i *= 2) {
count++;
}
cout << count;
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;
}
}
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;
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;
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;
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;
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;
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;
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;