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
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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started