Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def LongestDecreasing(lista_in):
- lista_out = []
- c = 0
- for element in lista_in:
- if element < lista_out[-1]:
- lista_out.append(element)
- else:
- binarySearch(lista_out,element)
- lista_out[]
- def binarySearch(alist, item):
- first = 0
- last = len(alist)-1
- found = False
- while first<=last and not found:
- midpoint = (first + last)//2
- if alist[midpoint] == item:
- found = True
- else:
- if item < alist[midpoint]:
- last = midpoint-1
- else:
- first = midpoint+1
- return found
- testlist = [0, 1, 2, 8, 13, 17, 19, 32, 42,]
- print(binarySearch(testlist, 3))
- print(binarySearch(testlist, 21))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement