18 lines
484 B
Python
18 lines
484 B
Python
from math import floor
|
|
|
|
recursive_sum = lambda n: 1 if n == 1 else n + recursive_sum(n - 1)
|
|
|
|
merge_sum = lambda lst: lst[0] if len(lst) == 1 else merge_sum(lst[0:floor(len(
|
|
lst) / 2)]) + merge_sum(lst[floor(len(lst) / 2):len(lst)])
|
|
|
|
|
|
def find_smallest_element(lst):
|
|
if len(lst) == 1: return lst[0]
|
|
smallest_element = find_smallest_element(lst[1:])
|
|
return lst[0] if lst[0] < smallest_element else smallest_element
|
|
|
|
|
|
def binary_search(numbers, element):
|
|
|
|
return -float('inf')
|