Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++ please! Binary Search Given the code below, complete the binary search function where the data is sorted in descending order. The function will

In C++ please! Binary Search

Given the code below, complete the binary search function where the data is sorted in descending order. The function will return the vector slot where the input target is found. If the target is not found, return -1.

Examples: (assume the vector is 60, 50, 40, 30, 20, 10)

input:

50 

output:

1 

input:

15 

output:

-1

image text in transcribedimage text in transcribed

Given the code below, complete the binary search function where the data is sorted in descending order. The function will return the vector slot where the input target is found. If the target is not found, return-1. Examples: (assume the vector is 60,50, 40, 30, 20, 10) input: 50 output: 1 input: 15 output: -1 1 #include 2 #include 3 using namespace std; 4 5 //execute a binary search algorithm against a DESCENDING orderered list and return 6 //the vector slot where target is found, if target not found then return -1 7 int BinarySearch (vector values, int target) 8 { 9} 10 11 int main() 12 { 13 vector> user Input; 17 cout

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

More Books

Students also viewed these Databases questions

Question

Prove that div ( f g) = 0?

Answered: 1 week ago

Question

b. Will new members be welcomed?

Answered: 1 week ago

Question

c. Will leaders rotate periodically?

Answered: 1 week ago

Question

b. Will there be one assigned leader?

Answered: 1 week ago