Question
bool binarySearch(std::vector myvector, int search, std::string type) { int mid; int low = 0; int high = myvector.size() - 1; while (low midVlaue ){ low
bool binarySearch(std::vector
if(type == myvector[mid].putType()) find = 0; if (search == midVlaue && find == 0 ){ return mid; } else if (search > midVlaue ){ low = mid + 1; } else { high = mid - 1; } } return false; } bool linearSearch(std::vector
I would like to know how to find integer and string in the vector with binary search. I can find with linear search but I don't know how to do with binary search
For example,
34,new
45,used
35,digital
I want to find "34,new". It has to be same number and type. If I find "34,used" it shouldn't be executable. When I find with linear search the answer correct but binary sear is incorrect.
please help me with add in binary search function. Thanks
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started