插值查找python和C++实现
python版
class insert_search():
def search_insert(self, list, item):
low = 0
high = len(list) - 1
while(low <= high):
mid = low + (high - low) * (item - list[low]) // (list[high] - list[low])
guess = list[mid]
if guess == item:
return mid
elif guess > item:
high = mid - 1
else:
共有 0 条评论