Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def linear_search(list,size,item):
- for i in range(0, size):
- if list[i] == item:
- return i
- return -1
- list = [5,6,7,8,9,10,11,12,31,41,47,85,77]
- size = len(list)
- item = 85
- index = linear_search(list,size,item)
- if (index == -1):
- print('item not found ')
- else:
- print('item found on index:',index+1)
Advertisement
Add Comment
Please, Sign In to add comment