# create a list of numbers
num = [10, 20, 30, 40, 50]
# access the third element in the list
third_element = num[2]
#change the value at index 0
num[0] = 5
# add a new element to the end of the list
num.append(60)
#remove the third element in the list
del num[3]
#find the length of the list
list_length = len(num)
import math
def wrstCase(arr_length):
return math.log2(arr_length)
arr_length = 20
worstCaseIterations = wrstCase(arr_length)
print(f"Worst case binary search iterations for an array of length {arr_length}: {worstCaseIterations:.2f}")
Homework 3
A because the program is moving each number in the array into a new one. Then, every number is getting multiplied by two in the array. Therefore the final answer will just be the array multiplied by two.