00:01
Now we're animating binary search instead of linear search.
00:04
The big difference is that binary search does not check every item one by one.
00:08
It keeps cutting the search range in half.
00:11
Because binary search only works on a sorted list, this program starts with the numbers 1 through 20 in order.
00:17
And then we keep track of the current search range using two variables, low and high.
00:24
So we need self.
00:26
Low and self .high.
00:29
So self dot values equal 1, 2, 3, all the way.
00:34
To 20.
00:37
Self.
00:38
Low equals zero.
00:41
Self.
00:41
High equals one.
00:47
Self dot values.
00:49
Whoops, negative one.
00:55
Each time the user clicks step, the program finds the middle position.
01:00
So the middle index would be mid equals low plus high divided by two.
01:05
In python, that would be mid equals self...