数据结构与算法(查找)
1.顺序查找
def linear_search(data_list, value): for index, i in enumerate(data_list): if i == value: return index else: return None
2.二分查找(折半查找)
def binary_search(data_list, value): left = 0 right = len(data_list) while left <= right: mid = (left + right) // 2 if mid == value: return mid elif mid < value: left = mid + 1 else: right = mid -1 else: return None
3.