Question: Consider the following code, which is called by a client with a list of integers. def someFunction(aList): n = len(aList) for i in range(n): print
Consider the following code, which is called by a client with a list of integers.
def someFunction(aList): n = len(aList) for i in range(n): print (aList[i]) for j in range(n): print(aList[j] + 1) print(aList[j] + 2)
Select from the options below the complexity of the code.
You may assume that the length of aList (n, in this program) is the size of the problem and a step (i.e. the basic unit of computation) is the print() statement.
For the purpose of this question, you can ignore the complexity of any other parts of the program, such as assignments, addition, the index and len() functions.
Select one:
O(n2)
O(1)
O(2n + n + 1)
O(n3)
O(n)
O(nm)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
