We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
原谅:
def binarySearch(lst, value,low,high): #low,high是lst的查找范围 if high < low: return -1 mid = (low + high)/2 if lst[mid] > value: return binarySearch(lst, value, low, mid-1) elif lst[mid] < value: return binarySearch(lst, value, mid+1, high) else: return mid
最后应该是 return lst[mid]
另外 当 high< low 时 返回-1 ,对此不解。 应该返回None
The text was updated successfully, but these errors were encountered:
No branches or pull requests
原谅:
也可以不用递归方法,而采用循环,如下:
最后应该是
return lst[mid]
另外 当 high< low 时 返回-1 ,对此不解。 应该返回None
The text was updated successfully, but these errors were encountered: