What is the time complexity of this code
int a = 0, i = N;
while (i > 0)
{
a += i;
i /= 2;
}
ANALYSIS OF ALGORITHMS
Quiz
•
Computers
•
University
•
Hard
POOJA SAPRA
Used 419+ times
FREE Resource
15 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What is the time complexity of this code
int a = 0, i = N;
while (i > 0)
{
a += i;
i /= 2;
}
O(N)
O(Sqrt(N))
O(N / 2)
O(log N)
2.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
The complexity of Binary search algorithm is
O(n)
O(log n)
O(n2)
O(n log n)
3.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
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;
}
}
O(N)
O(N*log(N))
O(N * Sqrt(N))
O(N*N)
4.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
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;
}
}
O(n)
O(nLogn)
O(n^2)
O(n^2Logn)
5.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
A linear function takes the form
f(n) = an + b
f(n) = an2 +bn + c
f(n) = alog2n
f(n) = a + b
6.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Find the slowest algorithm:
O (n)
O (n^2)
O (n!)
O (2^n)
7.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
The number of executions grows extremely quickly as the size of the input increases
Exponential Time
Linear Time
Polynomial Time
Constant Time
10 questions
27Mar
Quiz
•
University
10 questions
Complexity Quizz
Quiz
•
University
13 questions
DS UNIT-2 TEST-2
Quiz
•
University
13 questions
Preliminary Algorithm and Complexities Examination
Quiz
•
University
10 questions
Algorithm analysis: divide & conquer theory
Quiz
•
University
10 questions
Analysis of Algorithms
Quiz
•
University
10 questions
DAA Quiz 1
Quiz
•
University
20 questions
Quantitative Aptitude Series
Quiz
•
University
15 questions
Character Analysis
Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing
Quiz
•
9th - 12th Grade
10 questions
American Flag
Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension
Quiz
•
5th Grade
30 questions
Linear Inequalities
Quiz
•
9th - 12th Grade
20 questions
Types of Credit
Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25
Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers
Quiz
•
6th - 8th Grade