Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help me fix... If i delete the last line where it is to print out the string it works fine, but i can't get it

Help me fix... If i delete the last line where it is to print out the string it works fine, but i can't get it to print out the string....

#include #include using namespace std;

template

int binarySearch(const T list[], T key, int arraySize) { int low = 0; int high = arraySize - 1; while (high >= low)

{ int mid = (low + high) / 2; if (key < list[mid]) high = mid - 1; else if (key == list[mid]) return mid; else low = mid + 1; } return-low - 1; }

int main() { int intList[] = { 2,4,6,8,10 }; double doubleList[] = { 1.1,3.3,5.5,7.7,9.9 }; string stringList[] = { "ABC","DEF","GHI","JKL"};

cout << binarySearch(intList, 4, 5) << endl; cout << binarySearch(doubleList, 7.7, 5) << endl; cout << binarySearch(stringList, "ABC", 4) << endl;

}

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

Unity From Zero To Proficiency Beginner A Step By Step Guide To Coding Your First Game

Authors: Patrick Felicia

1st Edition

1091872023, 978-1091872028

More Books

Students also viewed these Programming questions