2021) Asymptotic Worst Case Time and Space Complexity
2021) Asymptotic Worst Case Time and Space Complexity
Score Card For Algorithms Topic Test – 1(2021)Asymptotic worst case time and space complexity
Total Marks of 25.00 My Percentile 54.58% Right Marks 15.00 Negative 1.32
Test Marks
Performance Report For Algorithms Topic Test – 1(2021)Asymptotic worst case time and space complexity
Question & Marks Wise Report For Algorithms Topic Test – 1(2021)Asymptotic worst case time and space
complexity
Subject Report For Algorithms Topic Test – 1(2021)Asymptotic worst case time and space complexity
Graphical Report For Algorithms Topic Test – 1(2021)Asymptotic worst case time and space complexity
Time Management For Algorithms Topic Test – 1(2021)Asymptotic worst case time and space complexity
Question Report For Algorithms Topic Test – 1(2021)Asymptotic worst case time and space complexity
testseries.ravindrababuravula.com/crm/Results/printresult/126651 1/31
3/23/2021 Download PDF
1 Consider the following statements g(n) is g(n) is O(h(n)) 1.00 1.00 2 Easy
O(h(n)) and and h(n) is Mins
S1: f(n) = n3
h(n) is Ω(f(n)) 14
S2: g(n)= n2 logn Ω(f(n)) Sec
4 The time complexity of an algorithm T(n), O(logn) O(logn) 1.00 1.00 3 Easy
where n is input size is given by Mins
29
T(n)= T(n-1)+1/n, if n>1
Sec
= 1, otherwise
testseries.ravindrababuravula.com/crm/Results/printresult/126651 2/31
3/23/2021 Download PDF
6 Find the most appropriate matching for P-6, Q-1, R- P-6, Q-1, R-2, 2.00 2.00 1 Easy
the following pairs 2, S-3 S-3 Mins
43
Sec
7 Find the recurrence relation and its time 3T(n/2)+1 2T(n/2)+1 2.00 -0.66 5 Easy
complexity for given code segment and O(n2) and O(n) Mins
25
Sec
testseries.ravindrababuravula.com/crm/Results/printresult/126651 3/31
3/23/2021 Download PDF
8 Find the worst-case time complexity for O(n6) O(n6) 2.00 2.00 49 Easy
given code segment Sec
9 Find the worst case time complexity of a O(n3) O(log2n) 2.00 -0.66 1 Easy
given algorithm? Mins
48
Sec
testseries.ravindrababuravula.com/crm/Results/printresult/126651 4/31
3/23/2021 Download PDF
10 Find the time complexity of a given O(2n) O(2n) 2.00 2.00 1 Easy
recursion code segment is ___? Mins
42
Sec
11 What is the worst case time complexity of O(n3log2n) O(n3log2n) 2.00 2.00 1 Easy
below code segment Mins
40
Sec
12 State TRUE/FALSE for given statements S1-FALSE S1-FALSE 2.00 2.00 2 Easy
and S2- and S2- Mins
S1: 2T(n/2)-4T(n/2)+1 is solvable by using
FALSE FALSE 10
the master's theorem.
Sec
S2: If for an algorithm time complexity is
given by O((3⁄2)n) then complexity will be
linear.
testseries.ravindrababuravula.com/crm/Results/printresult/126651 5/31
3/23/2021 Download PDF
13 Arrange the following functions in f4(n) > f1(n) f4(n) > f1(n) > 2.00 2.00 5 Easy
decreasing asymptotic order. > f3(n) > f3(n) > f5(n) > Mins
f5(n) > f2(n) f2(n) 34
Sec
testseries.ravindrababuravula.com/crm/Results/printresult/126651 6/31
3/23/2021 Download PDF
15 1 2.00 54 Easy
Sec
Solution For Algorithms Topic Test – 1(2021)Asymptotic worst case time and space complexity
Question: 1
Consider the following statements
1.
2.
3.
4.
Max Marks : 1.00 Marks Scored : 1.00 Time Taken : 2 Mins 14 Sec
testseries.ravindrababuravula.com/crm/Results/printresult/126651 7/31
3/23/2021 Download PDF
Solution :
The asymptotic notations are following the given order.
Constant < logarithmic < linear < polynomial < exponential < factorial
Option-B: FALSE: f(n)=O(h(n)) and h(n)≠O(g(n)) because g(n) is asymptotically smaller than h(n).
Option-C: FALSE: g(n)=O(h(n)) and f(n)≠O(g(n)) because f(n) is greater than g(n). So we can represent f(n)=O(h(n))
instead of f(n)=O(g(n))
Option-D: TRUE: g(n)=O(h(n)) and h(n)=Ω(f(n)) because g(n) is smaller than h(n) and f(n) is smaller than h(n).
Question: 2
Follow the given conditions
1.
2.
3.
4.
testseries.ravindrababuravula.com/crm/Results/printresult/126651 8/31
3/23/2021 Download PDF
Max Marks : 1.00 Marks Scored : Time Taken : 1 Mins 26 Sec
Solution :
According to given conditions Bob < John < Alice in terms of BigOh notations.
Option-A: FALSE: Bob=O(Alice) and Alice≠O(John) because Alice will take maximum time to reach 100 meters.
Question: 3
Find the time complexity of a given recurrence relation using recursion tree method.
1.
O(n)
2.
O(nlogn)
3.
O(n2)
4.
O(n2 logn)
Max Marks : 1.00 Marks Scored : Time Taken : 48 Sec
Solution :
testseries.ravindrababuravula.com/crm/Results/printresult/126651 9/31
3/23/2021 Download PDF
Method-2: We can get time complexity by looking at recurrence relation because n2 is the leading term among
all. We can directly conclude time complexity is O(n2).
Question: 4
The time complexity of an algorithm T(n), where n is input size is given by
= 1, otherwise
testseries.ravindrababuravula.com/crm/Results/printresult/126651 10/31
3/23/2021 Download PDF
1.
O(logn)
2.
O(n)
3.
O(nlogn)
4.
O(1)
Max Marks : 1.00 Marks Scored : 1.00 Time Taken : 3 Mins 29 Sec
Solution :
T(n) = T(n-1) + 1/n --- (I)
⋮
T(1) = 1
So, n-k = 1
k = n-1
= O(log n)
testseries.ravindrababuravula.com/crm/Results/printresult/126651 11/31
3/23/2021 Download PDF
Question: 5
Consider the following function
1.
O(n)
2.
O(log2n)
3.
O(nlogn)
4.
O(loglog2n)
Max Marks : 1.00 Marks Scored : 1.00 Time Taken : 1 Mins 59 Sec
Solution :
testseries.ravindrababuravula.com/crm/Results/printresult/126651 12/31
3/23/2021 Download PDF
Question: 6
Find the most appropriate matching for the following pairs
1.
2.
3.
4.
Max Marks : 2.00 Marks Scored : 2.00 Time Taken : 1 Mins 43 Sec
Solution :
testseries.ravindrababuravula.com/crm/Results/printresult/126651 13/31
3/23/2021 Download PDF
testseries.ravindrababuravula.com/crm/Results/printresult/126651 14/31
3/23/2021 Download PDF
Question: 7
Find the recurrence relation and its time complexity for given code segment
1.
2.
3.
4.
Max Marks : 2.00 Marks Scored : -0.66 Time Taken : 5 Mins 25 Sec
testseries.ravindrababuravula.com/crm/Results/printresult/126651 15/31
3/23/2021 Download PDF
Solution :
→ In recursion code segments we will consider only the recursion part to nd time complexity. We never
consider the dependent value of the recursion function.
→ We will consider the recursion part in either “if” or “else” conditions. Both conditions will give the recurrence
relationship is Bob(n/2)+Bob(n/2)+1
We will not consider the dependent value of the else statement “3”.
T(n)=2T(n/2)+1
Case-1: a>b^k
⇒ 2>2^0
O(n^log22 n)
O(n)
Question: 8
Find the worst-case time complexity for given code segment
testseries.ravindrababuravula.com/crm/Results/printresult/126651 16/31
3/23/2021 Download PDF
1.
O(n6)
2.
O(n7)
3.
O(n4)
4.
O(n5)
Max Marks : 2.00 Marks Scored : 2.00 Time Taken : 49 Sec
Solution :
testseries.ravindrababuravula.com/crm/Results/printresult/126651 17/31
3/23/2021 Download PDF
Question: 9
Find the worst case time complexity of a given algorithm?
1.
O(log2n)
2.
O(log2n * log2log2n)
3.
O(n2 logn)
4.
O(n3)
Max Marks : 2.00 Marks Scored : -0.66 Time Taken : 1 Mins 48 Sec
testseries.ravindrababuravula.com/crm/Results/printresult/126651 18/31
3/23/2021 Download PDF
Solution :
if(1) condition is always TRUE and will never enter into “else” condition.
testseries.ravindrababuravula.com/crm/Results/printresult/126651 19/31
3/23/2021 Download PDF
Question: 10
Find the time complexity of a given recursion code segment is ___?
1.
O(log2n)
2.
O(2n)
3.
O(nlogn)
4.
Max Marks : 2.00 Marks Scored : 2.00 Time Taken : 1 Mins 42 Sec
testseries.ravindrababuravula.com/crm/Results/printresult/126651 20/31
3/23/2021 Download PDF
Solution :
The given code is nothing but the Tower of Hanoi.
testseries.ravindrababuravula.com/crm/Results/printresult/126651 21/31
3/23/2021 Download PDF
Question: 11
What is the worst case time complexity of below code segment
1.
O(n3log2n)
2.
O(n3)
3.
O(n4)
4.
O(n2 log2n)
Max Marks : 2.00 Marks Scored : 2.00 Time Taken : 1 Mins 40 Sec
testseries.ravindrababuravula.com/crm/Results/printresult/126651 22/31
3/23/2021 Download PDF
Solution :
→ The above code segment is a combination of iterative and recursion. Even though it is a combination of
iterative and recursion we have to nd worst case time complexity.
→ The above code segment given two independent loops so we have to identify which is larger to nd worst case
time complexity.
Question: 12
State TRUE/FALSE for given statements
S2: If for an algorithm time complexity is given by O((3⁄2)n) then complexity will be linear.
testseries.ravindrababuravula.com/crm/Results/printresult/126651 23/31
3/23/2021 Download PDF
1.
2.
3.
4.
Max Marks : 2.00 Marks Scored : 2.00 Time Taken : 2 Mins 10 Sec
Solution :
S1: FALSE: 2T(n/2)-4T(n/2)+1 is not solvable by using the master's theorem because masters theorem will allow
the recurrences in the form of aT(n/b)+f(n) or aT(n/b)+n^k log^p n.
S2: FALSE: If for an algorithm time complexity is given by O((3⁄2)n) then complexity will be exponential.
The growth rate of O((3⁄2)n) or O(1.5)n function will be exponential therefore complexity will be exponential.
Question: 13
Arrange the following functions in decreasing asymptotic order.
1.
2.
3.
4.
Max Marks : 2.00 Marks Scored : 2.00 Time Taken : 5 Mins 34 Sec
testseries.ravindrababuravula.com/crm/Results/printresult/126651 24/31
3/23/2021 Download PDF
Solution :
We can solve this problem by 2 methods:
2. Using asymptotic growth functions( constant, logarithmic, linear, polynomial and exponential)
Step-1:
testseries.ravindrababuravula.com/crm/Results/printresult/126651 25/31
3/23/2021 Download PDF
Question: 14
Max Marks : 2.00 Marks Scored : Time Taken : 7 Sec
Solution :
Explanation:
This type of problem, we have to consider worst case time complexity, it means that all possibilities.
According to the ow chart, there are a total 7 worst case possibilities of function calls.
testseries.ravindrababuravula.com/crm/Results/printresult/126651 26/31
3/23/2021 Download PDF
The remaining function calls/return statements will execute only a constant amount of time.
The remaining function calls/return statements will execute only a constant amount of time.
testseries.ravindrababuravula.com/crm/Results/printresult/126651 27/31
3/23/2021 Download PDF
Question: 15
Max Marks : 2.00 Marks Scored : Time Taken : 54 Sec
Solution :
ompare Report For Algorithms Topic Test – 1(2021)Asymptotic worst case time and space complexity
testseries.ravindrababuravula.com/crm/Results/printresult/126651 28/31
3/23/2021 Download PDF
testseries.ravindrababuravula.com/crm/Results/printresult/126651 29/31
3/23/2021 Download PDF
testseries.ravindrababuravula.com/crm/Results/printresult/126651 30/31
3/23/2021 Download PDF
testseries.ravindrababuravula.com/crm/Results/printresult/126651 31/31