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.
You should write these functions and include them in your program:
void initialize(bool primeList[]);
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.
13 years ago 5
Answer(1)
Purchase the answer to view it
NOT RATED
- for_x.docx
Bids(1)
other Questions(10)
- write the standard form of the equation of the circle with the given center and radius (0,-8);8
- block A, with a weight w, slides down an inclined plane S of slope angle 37.0 degree at a...
- Write your own song about the impact of the settlement of the west on different groups of people. Use the...
- Suppose an in-line skater skates around a park that has the shape of a regular pentagon. If he skates once...
- Algebra MyMathLab 18 questions
- Given the unconstrained function, F = x₁² + 1/x₁ + x₂ + 1/x₂ Question(a) At x₁ =2 & x₂ = 2,...
- Informatic report / medical/
- X= the square root of 5X +10
- Choose two of these features and find out what they are. Describe how they were formed, using diagrams if necessary....
- essay