Create list of Prime Numbers- You are going to create a Queue (specific type of Linked List). You will then fill it with numbers consecutively numbered from 2 to n where n is entered by the user. When creating your Queue object use the correct function names for enqueue and dequeue.

Create a second List - this one should be a Queue - it is empty.

Once you have the first List filled we are going to use a technique called Sieve of Eratosthenes which uses first queue to fill the second queue. You will need to look at the algorithm for this

Here is the simple method to do this - L1 is the first list, Q1 is the Queue.

1. Go to 1st element in L1 (which will be 2).
2. Because it exists - Enqueue this into Q1 and dequeue it from L1
3. Iterate through each element of L1 and if the value is divisible by 2 dequeue it.
4. When done go back to the beginning of the list (the value will be 3 the second time around)
5. Print Iteration 1, Value of L1 (all elements) and Q1 (all elements)
6. Repeat steps 2-5 with this new element - repeat until L1 is empty.

Sample output with input 10

Iteration 0: L1 = 2 3 4 5 6 7 8 9 10, Q1 = ,
Iteration 1: L1 = 3 5 7 9, Q1 = 2
Iteration 2: L1 = 5 7, Q1 = 2 3
Iteration 3: L1 = 7, Q1 = 2 3 5
Iteration 4: L1 = , Q1 = 2 3 5 7
Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.