Question
Line 1: def average(inputList): Line 2: n = len(inputList) Line 3: total = 0 Line 4: for i in range(n): Line 5: total += inputList[i]
Line 1: def average(inputList):
Line 2: n = len(inputList)
Line 3: total = 0
Line 4: for i in range(n):
Line 5: total += inputList[i]
Line 6: return total / n
Analyze the time complexity of the above program. Your analysis should contain 1) a discussion on how many operations used per line, line 1 excluded. 2) what is the final representation of the complexity of this program, 3) what is the Big-O of the program, and 4) prove it following the formal denition of Big-O, 5) is your provided Big-O in answer to 3) the tighest upper bound? Why? provide a short discussion.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started