From 192ff531959c2a90ba490aa5bb6e766ad478aa87 Mon Sep 17 00:00:00 2001 From: saradiya <56483022+saradiya@users.noreply.github.com> Date: Sat, 12 Oct 2019 21:28:07 +0530 Subject: [PATCH] some updates with if loop --- linearSearch.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/linearSearch.py b/linearSearch.py index 496a5ba..bc35994 100644 --- a/linearSearch.py +++ b/linearSearch.py @@ -16,6 +16,12 @@ def func(arr,n, x): n = len(arr) result = func(arr, n,x) +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 if (result==-1): print("value",x," not found in array")