comparison async_multi_threads/binary_search.py @ 69:551d9fc0a2ba

Updated wrong names.
author June Park <parkjune1995@gmail.com>
date Thu, 25 Dec 2025 20:07:46 -0800
parents
children
comparison
equal deleted inserted replaced
68:70ca1d99f3fd 69:551d9fc0a2ba
1
2 x = [1,2,3,4,5,9,20,25,33,99]
3 # | |
4
5 target = 18
6 left = 0
7 right = len(x)
8
9 while left < right:
10 mid = (left + right)//2
11 if x[mid] == target:
12 break
13 elif x[mid] < target:
14 left = mid + 1
15 else:
16 right = mid
17
18 print(x[mid])