Finding the closest value

Hi All,

I am currently self-learning C++ with the arduino IDE and also using QT. I am trying to find a good code explanation on a binary search or a closest value search. I understand the way it is done, i am just not sure how to implement it. Every time i go to look at a video, all that gets to me is jibberish and the code i just dont understand.

So if anyone can produce some very simple code that explains this, i would appreciate thatplease. Help a brother out :wink:

(if possible both binary search and closest value)

Thank you !

For binary search, just remember the children's game " I'm thinking of a number between 1 and 100. What is it, based on clues of "higher or lower?"

For closest value, find the smallest absolute value of the difference of the values.

TheMemberFormerlyKnownAsAWOL:
For binary search, just remember the children's game " I'm thinking of a number between 1 and 100. What is it, based on clues of "higher or lower?"

For closest value, find the smallest absolute value of the difference of the values.

i dont suppose you have any working examples?

Did you Google, "binary search C++"?

aarg:
Did you Google, "binary search C++"?

nah i decided not too as i thought that would not give me any answers.

jacklythgoee:
nah i decided not too as i thought that would not give me any answers.

Well, whether you're joking (sarcastically) or not, it will, because it's a very common introductory computer science topic. You said you're looking at videos - wrong place to look for technical information.