in Algorithms edited by
16,346 views
61 votes
61 votes

The given diagram shows the flowchart for a recursive function $A(n)$. Assume that all statements, except for the recursive calls, have $O(1)$ time complexity. If the worst case time complexity of this function is $O(n^{\alpha})$, then the least possible value (accurate up to two decimal positions) of $\alpha$ is ________.

Flow chart for Recursive Function $A(n)$.

in Algorithms edited by
16.3k views

4 Comments

thanks sir 🙂

this clears all my doubt.
2
2

@Sachin Mittal 1
sir can we say by  “least possible value of ‘a’, they infer tightest upper bound?

0
0

@Debanjan_2000 yes right

1
1

2 Answers

103 votes
103 votes
Best answer
If they are asking for worst case complexity hence,
By calling $A(n)$ we get $A(n/2)$ $5$ times,

$A(n)=5A (n /2) + O(1)$

Hence, by applying masters theorem,
Case 1 : $a>b^k$

$n^{\log_25}$

Thus value of alpha will be $2.32$
edited by

4 Comments

What was the range of the answer then? 2.31-2.33 ?
0
0
In the scientific calculator when i typed log5/log2, it was showing 0.301(which is only the value of log2) because i hadn’t pressed enter button !!! this cost me 2 marks
1
1

masters theorem give Θ()big Theta but here we need O()big O.

please clarify

f(n) = Theta(g(n)), means

c1*f(n) <= g(n) <=c 2*f(n)

so basically g(n) is both upper bound and lower bound to f(n). hence whenever theta notation is given , big-oh and omega -oh are also meant.

0
0
9 votes
9 votes

This is a GATE 2016 question. https://gateoverflow.in/39581/gate2016-2-39

From the flow chart, you can see that, In worst case, We will have to call $A(n/2)$ $Five$ times. And in best case, Just Two times.

So, For Worst case time complexity, Recursive equation would be as follows :

$T(n) = 5T(\frac{n}{2}) + 1$

Now, Just apply Master's theorem :

$T(n) = \Theta(n^{log_2 \,5})$ (In worst case)

Hence, $\alpha = log_2\,5 = 2.32$

Answer:

Related questions