Computer scienceProgramming languagesC++Introduction to STL (Containers and Algorithms)

Advanced algorithms of STL

Theory

Search a number

Report a typo

Write a C++ function called binarySearchArray that takes a sorted array, size and a target element as parameters. The function should return a boolean indicating whether the target element is present in the array using the binary search algorithm.

Sample Input 1:

3

Sample Output 1:

Element 3 found.

Sample Input 2:

11

Sample Output 2:

Element 11 not found.
Write a program in C++
bool binarySearchArray(const int sortedArray[], int size, int target) { }

Create a free account to access the full topic