The running time of the following algorithm
Procedure
If return () else return ;
is best described by
View worked solution
Answer: C
To find the running time of the procedure , we can write its recurrence relation. Let be the time complexity of the algorithm for an input size :
To solve this recurrence, we can ignore the ceiling function for asymptotic analysis and use the change of variables method.
Let , which implies . Substituting this into the recurrence:
Let . The recurrence relation becomes:
Applying the Master Theorem (Case 2) or by simple expansion, we get:
Now, substituting back into the solution:
Thus, the running time of the algorithm is best described by .
Free practice · Your answers on this page are not saved.
