Time complexity: O(log2log2N), complexity of using log(N) is log(logN), and pow(x,N) is log(N), so pow(2,0.5*log(n)) will be log(logN). Auxiliary space: O(1)
How does the above program work?
let d be our answer for input number n
then n(1/2) = d
apply log2 on both sides
log2(n(1/2)) = log2(d)
log2(d) = 1/2 * log2(n)
d = 2(1/2 * log2(n))
d = pow(2, 0.5*log2(n))
This article is contributed by Tumma Umamaheswararao from Jntuh College of Engineering . If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Please Login to comment...