Example. To look for in the order table 7,14,18,21,23,29,31,35,38} {18.

“Resolution”

There are a couple of things we need to know when we’re halfway looking for one of the elements in an ordered list

First, we need to sort the elements of the table from smallest to largest. We don’t need to sort the elements of the table since they are ordered (remember this step is important).

As the name implies, the elements in the table are divided into half to narrow the scope of search, so we need to introduce two variables low, high and mid, where low indicates the first element is halved every time, high indicates the last element is halved every time, and MID represents the middle element.

So now that we’ve got these two concepts we need to draw a picture of how to find it, okay

Put the elements in the order table first.

【 First comparison 】

Mid =(9+!) PI over 2 is equal to 5, which is 23, because 23 is greater than 18 and we need to move high to the left of mid and high is equal to 4

【 Second comparison 】

The second time I look it up mid is going to be equal to (4+1)/2 is going to be equal to 2 and it’s going to be equal to 14, and since 14 is less than 18, I’m going to move low to the right of mid and low is going to be equal to 3

【 Third Comparison 】

Mid =(3+4)/2=3, mid=(3+4)/2=3, mid=(3+4)/2=3, mid=(3+4)/2=3, mid=(3+4)/2=3, mid=(3+4)/2=3, mid=(3+4)/2=3)

【 note 】

I have to add a little bit here, so the first thing we do is we take mid, so mid is equal to low plus high over 2, and we get a round here

The second is that after we calculate the value of mid, if the value of mid is greater than the value we are looking for, then high will move right to the left of mid

If the value of mid is less than the value we are looking for, low will move to the right of mid