wiz-icon
MyQuestionIcon
MyQuestionIcon
1
You visited us 1 times! Enjoying our articles? Unlock Full Access!
Question

The running time of the following algorithm procedureA(n)
If n < = 2 return (1) else return (A(n )); is best described by

A
O(log log n)
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
B
O(1)
No worries! We‘ve got your back. Try BYJU‘S free classes today!
C
O(n)
No worries! We‘ve got your back. Try BYJU‘S free classes today!
D
O(log n)
No worries! We‘ve got your back. Try BYJU‘S free classes today!
Open in App
Solution

The correct option is A O(log log n)
Recursive relation for procedure A(n) is
T(n) = T(n) + c1 if n > 2
Let n = 2m
T(n) = T(2m)
T(2m) = S(m)
T(n) = S(m)
T(n) = T(2m/2) = S(m/2)
T(n) = T(n) + c1 is n > 2
S(m) = S(m2) + c1
= O(log m)
= O(log log n) [ n= 2m m = log m]
T(n) = S(m)
= O(log log n)
Option (c) is correct.

flag
Suggest Corrections
thumbs-up
0
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Laws of Logarithm with Use
MATHEMATICS
Watch in App
Join BYJU'S Learning Program
CrossIcon