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

FIRST GRADER essay writing company is the ideal place for homework help. If you are looking for affordable, custom-written, high-quality and non-plagiarized papers, your student life just became easier with us. Click the button below to place your order.


Order a Similar Paper Order a Different Paper

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:

Got stuck with another paper? We can help! Use our paper writing service to score better grades and meet your deadlines.

Get 15% discount for your first order


Order a Similar Paper Order a Different Paper
Writerbay.net