File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -76,3 +76,38 @@ def binarysearch(arr,target):
7676# Average Case: O(log N)
7777# Worst Case: O(log N)
7878# Auxiliary Space: O(1), If the recursive call stack is considered then the auxiliary space will be O(logN).
79+
80+
81+ # Binary Search using While Loop
82+ # def search(arr,l,r,v):
83+ # while l<=r:
84+ # mid=l+(r-1)//2
85+ # if arr[mid]==v:
86+ # return mid
87+ # elif arr[mid]<r:
88+ # l=mid+1
89+ # else:
90+ # r=mid-1
91+ # return -1
92+
93+
94+ # Binary Search using Recursion
95+ # def search(arr,l,r,v):
96+ # if l<=r:
97+ # mid=l+(r-1)//2
98+ # if arr[mid]==v:
99+ # return mid
100+ # elif arr[mid]>r:
101+ # return search(arr,l,mid-1,v)
102+ # else:
103+ # return search(arr,mid+1,r,v)
104+ # return -1
105+
106+
107+
108+ # arr=[int(x)for x in input('array').split(",")]
109+ # v=int(input())
110+ # result=search(arr,0,len(arr),v)
111+ # print(result)
112+
113+
You can’t perform that action at this time.
0 commit comments