Update MP2

master
Caleb Fontenot 2024-03-07 13:27:19 +07:00
parent f3217d0614
commit 00e479a3a1
2 changed files with 21 additions and 0 deletions

@ -0,0 +1,21 @@
#include <iostream>
#include <vector>
#include <climits>
using namespace std;
int binarySearch(std::vector arr, int numToSearchFor) {
std::sort(arr);
int first = 0;
int last = arr.size() - 1;
int position = INT_MIN;
bool found = false;
while (!found && first <= last) {
middle = (first + last) / 2;
if (arr[middle] == numToSearchFor) {
found = true;
position = middle;
}
}
}