問題詳情

20. You are given a Python function that is supposed to implement the binary search algorithm to find the index of a target element in a sorted list. However, there is a mistake in the code. Identify the mistake and provide the corrected version of the code.
  


(A) Change len(arr) to len(arr)-1
(B) Change the condition in the while loop to while left<right
(C) Change left=mid+1 to left=mid
(D) Change right=mid-1 to right=mid
(E) Add a condition to handle the case when the target is not found in the list

參考答案

答案:A

統計:A:0,B:0,C:0,D:0,E:0

難度:計算中