diff --git a/linearSearch.py b/linearSearch.py index 496a5ba..1955083 100644 --- a/linearSearch.py +++ b/linearSearch.py @@ -5,6 +5,12 @@ def func(arr,n, x): for i in range(0,n): if (arr[i] == x): return i + if(arr[mid] == x): + return mid + + #if not and value is greater than mid value ignore left part and increase its value + elif arr[mid] < x: + l = mid+1 return -1