Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

*Program is in C* Write a program using linked lists to find prime numbers up to 1000 using the sieve method. A prime number Ls

image text in transcribed

*Program is in C*

Write a program using linked lists to find prime numbers up to 1000 using the sieve method. A prime number Ls a whole number greater than 1. whose only two whole-number factors are 1 and itself. For example, 4 is not a prime number since its factors are 1, 2 and 4. 7 is a prime number since its factors are 1 and 7. The first few prime numbers are 2, 3, 5, 7, 11, 13, 17, 19, 23, and 29. You can follow below steps to find the prime numbers (a) Build a linked list consisting of integers 1 to 1000. You can use the following methods discussed in the class for this step. node *inserthead(node *head, int a) node *inserttail(node *head, int a) (b) Implement a method to delete all the multiples of an integer k from the linked list. This method returns the new list. node *deletemultiples(node *head, int k) Use this method to delete all the multiples of 2..32 from the linked list. You need to use delete-multiples method for each number from 2 to 32 to delete the multiples of that number. (c) The remaining numbers will be prime numbers. Print the linked list to see the prime numbers. The first few prime numbers are 2, 3, 5, 7, 11, 13, 17, 19, 23, and 29 and should be part of your output

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

1 2 3 Data Base Techniques

Authors: Dick Andersen

1st Edition

0880223464, 978-0880223461

More Books

Students also viewed these Databases questions