Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can anyone use C++ to solve this problem? Based on Problem P11.6 Implement a function bool binary.search (vector & v, int value, int & m)

Can anyone use C++ to solve this problem?image text in transcribedimage text in transcribed

Based on Problem P11.6 Implement a function bool binary.search (vector & v, int value, int & m) . that uses binary search to find out whether there is an integer value in the vector v of integers. If a match is found, the function returns true, otherwise it returns false. In the above function m is a reference parameter. which must be set to the location of the match if the search was successful. If value were not found, set m to the index of the next larger value instead, or to v.size() if value is larger than all the elements of the vector. Write a program that reads the list of integers from a file data3.txt and displays them on the screen. Then the program must sort the numbers using sort function from C+ library and then display the sorted vector. Finally, implement a loop in which the user is asked to enter a value, which is then searched in the sorted array using the above binary-search function. If value is found display "Found. m-" followed by the value of m. Otherwise display "Not found. m-" followed by the value of m . You can assume that data3.txt contains only integers (no floating point numbers or strings that are not numbers) and that the file has at least one number. . Submit the solution as hmw 5-3.cpp

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

Oracle Database Administration The Essential Reference

Authors: Brian Laskey, David Kreines

1st Edition

1565925165, 978-1565925168

More Books

Students also viewed these Databases questions