Prove the sieve of eratosthenes algorithm has runtime


Prove the Sieve of Eratosthenes algorithm has runtime complexity ≤ O(n log log n).

Sieve

Input: an integer n > 1.

Let A be an array of Boolean values, indexed by integers 2 to n, initially all set to true.

for i = 2,3,4,..., not exceeding √n:

if A[i] is true:

for j = i2,i2 + i,i2 +2i,i2 +3i,..., not exceeding n:

A[j] := false.

Output: all i such that A[i] is true.

Solution Preview :

Prepared by a verified Expert
Business Management: Prove the sieve of eratosthenes algorithm has runtime
Reference No:- TGS02915027

Now Priced at $10 (50% Discount)

Recommended (95%)

Rated (4.7/5)