'''
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.
'''
def binarysearch(g,iskat,start,stop):
if start > stop:
return False
else:
mid = (start+stop) // 2
if iskat == g[mid]:
return mid
elif iskat < g[mid]:
return binarysearch(g, iskat, start, mid-1)
else:
return binarysearch(g, iskat, mid+1 , stop)
g = ["ddd", "fff", "hello" , "hi" , "sss", "world"]
iskat = "sss"
start = 0
stop = len(g)-1
x = binarysearch(g, iskat, start, stop)
if x:
print("Item", iskat, "Found at index", x)
else:
print("Item", iskat, "Not Found")