Code:
Note:- Scroll horizontally to see the full line of code.
def sentinel_search(a,target):
# a is list of intergers and target is key element to be searched
a.append(target)
i=0
while(a[i]!=target):
i+=1
if(i<(len(a)-1)):
print(target,"is present at index",i)
else:
print(target,"not found in list")
Comments
Post a Comment