Reputation: 91
The running time of "sieve of sundaram" for generating a list of prime numbers upto a number n is given O(n*log(n)), according to the link: http://en.wikipedia.org/wiki/Sieve_of_Sundaram. Is this algorithm better than "Sieve of Atkin" and if it is then elaborate a little about how exactly it works?
Upvotes: 3
Views: 7154
Reputation: 11489
In theory:
In practice, the sieve of Sundaram is so slow that no one uses it, and the sieve of Atkin is slower than optimized Eratosthenes variants (although it's at least competitive). Perhaps one day Atkin or something else will displace Eratosthenes but it's not likely to happen soon. (Also, there's no such thing as magic.)
Upvotes: 9
Reputation: 35818
Well, the Wikipedia page for the Sieve of Atkin says:
This sieve computes primes up to N using O(N/log log N) operations
This is better than the Sieve of Sundaram, which is Θ(N log N) in operations (note that this is not O(N log N) -- there's a subtle difference between O() and Θ()).
Upvotes: 2