How the complexity for prime sieve came as nloglogn,
it would be helpful in understanding the concept of time complexity calculation
How did thi O(n*log(logn)) came as the comolexity?
Understanding the n*log(log n) time complexity of Sieve of Eratosthenes
-
If it is assumed that the time taken to mark a number as composite is constant, then the number of times the loop runs is equal to:
-
On taking n common from the above equation, the above equation can be rewritten as:
-
It can be proved as below with the help of Harmonic Progression of the sum of primes :
-
On substituting this in the equation, we get the time complexity as:
i hope this help
if you have more doubts regarding this feel free to ask
if your doubt is resolved mark it as resolved from your doubt section inside your course
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.