Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribedimage text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database And SQL

Authors: Lucy Scott

3rd Edition

1087899699, 978-1087899695

More Books

Students also viewed these Databases questions