Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have the directions and code from the previous part here. Change isprime::operator to use a binary search instead of the linear search implemented by

I have the directions and code from the previous part here.

image text in transcribedimage text in transcribedimage text in transcribed

Change "isprime::operator" to use a binary search instead of the linear search implemented by "findO" to determine if input N is a prime number. You are encouraged to use "binary searchO" from STL to do the job. Note that this algorithm returns a boolean that indicates whether the number N was found or not. Now change the driver code in the main program. First, have it use an optional command line argument to set the number of integers to test. Call this number N. If no command line argument is present, use N-10 as the default. Seed the random number generator with N. See the "clibstd" family of functions for "srandO". Second, generate a list of N random numbers in the range 1-100. As a suggestion, write a function object for producing each random number using "randO" while letting "generate" from STL fill in the list. Feel free to represent the list using a "vector" which you may recall is an array-based sequence container. Third, use "transformO" from STL along with function object "isprime" to obtain a boolean array that indicates which random number is prime. Feed this array to "count" from STL to determine how many prime numbers there are. Print the result to stdout as shown below

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_2

Step: 3

blur-text-image_3

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

Structured Search For Big Data From Keywords To Key-objects

Authors: Mikhail Gilula

1st Edition

012804652X, 9780128046524

More Books

Students also viewed these Databases questions

Question

What is electric dipole explain with example

Answered: 1 week ago

Question

What is polarization? Describe it with examples.

Answered: 1 week ago

Question

What is DDL?

Answered: 1 week ago