Question: Textbook Programming Project #1, page 905: Submit PrimeQueue.java Read description in the text, and study the pseudo-code provided (also on Wikipedia (Links to an external

Textbook Programming Project #1, page 905: Submit PrimeQueue.java

Read description in the text, and study the pseudo-code provided (also on Wikipedia (Links to an external site.)). Then create a class named PrimeQueue.java that contains a public static method getPrimes(n), which returns a Queue of prime numbers up to n. I will test these programs with a simple test like:

Queue q = PrimeQueue.getPrimes(12345);

Please remove (or comment out) your System.out calls, as my testing will be external. Also be aware of the Big-O of your algorithm, as nesting loops too deep here will really slow down the algorithm and be very apparent upon testing. Above example finds 1474 prime numbers and runs fast no matter how it's coded. Bump that up to getPrimes(12345678) so there are 800k+ primes and it still should be able to find that in a couple seconds.

NOTE: The pseudo code in text indicates two Queues (numbers and result). If you use an array like a Queue for the numbers start, and kind of follow the Wikipedia example, and build the Queue on the final step, then the total process time can be much faster.

Textbook Programming Project #1, page 905: Submit PrimeQueue.java Read description in thetext, and study the pseudo-code provided (also on Wikipedia (Links to an

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!