Use an array of 10,000 Boolean values to represent the list of numbers. Initialize all the array elements to true….

Use an array of 10,000 Boolean values to represent the list of numbers. Initialize all the array elements to true
. To “mark out” a number, reset the corresponding array element to false
.

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

 

You should write these functions and include them in your program:

 

void initialize(bool primeList[]);

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

void markOutComposites(bool primeList[]);

void outputPrimes(ofstream &outFile, bool primeList[]);

 

The Sieve of Eratosthenes can be implemented with a simple, “brute force” algorithm that works correctly but is very slow due to a lot of unnecessary “marking out” of values that have already been marked out. With some careful, clever thought and clever coding, you can reduce the redundancy to make your program much faster.

Still stressed from student homework?
Get quality assistance from academic writers!

Order your essay today and save 25% with the discount code LAVENDER