You are to write a program that utilizes the Sieve of Eratosthenes to calculate all the prime… 1 answer below »

Overview You are to write a program that utilizes the Sieve of Eratosthenes to calculate all the prime numbers up to some integer n. You are to use your own array-based queue to perform the calculations. The technique you will use was developed by a Greek mathematician and poet Eratosthenes who lived in the third century BC. The design for the algorithm is as follows: 1. Write the code to build an array based queue 2. Query the user for the max number 3. Instantiate an array-queue and fill it with the consecutive integers 2 through n inclusive. 4. Instantiate an empty queue to store the prime numbers. 5. do { Obtain the next prime p by removing the first value from the queue of numbers. Put p into the queue of primes. Walk the queue of numbers, eliminating numbers divisible by p. } while (p 6. All remaining values in the numbers queue are prime, so remove them from the numbers queue and insert them into the primes queue. 7. Display the queue with the prime numbers as instructed below.

Attachments:

Looking for a similar assignment? Get help from our qualified experts!

"Our Prices Start at $9.99. As Our First Client, Use Coupon Code GET15 to claim 15% Discount This Month!!":

Order a Similar Paper Order a Different Paper