Download this Python file containing a series of functions. For each function, labelled parts a) through f), explain what the function does, and gives its best and worst case running times in big-O notation. Use n as the length of myList.
# a)
def partA(myList):
if len(myList) < 2:
return -1
return myList[0] + myList[1]
# b)
def partB(myList):
if len(myList) % 2 == 0:
partA(myList) + partA(myList)
else:
partA(myList)
#c)
def partC(myList):
max = myList[0]
for value in myList:
if value max:
max = value
print(max)
min = myList[0]
for value in myList:
if value < min:
min = value
print(min)
sum = 0
for value in myList:
sum = sum + value
print(sum)
#d)
def partD(myList):
i = 1
while i < len(myList):
print(myList[i])
i = 2*i
#e)
def partE(myList, valueToFind):
for i in range(len(myList)):
if myList[i] == valueToFind:
return i
return -1
#f)
def partF(myList):
products = []
for value1 in myList:
for value2 in myList:
products.append(value1*value2)
sum = 0
for product in products:
sum = sum + product
return sum