The python script uses an iterative way to calculate the max
value,
we iterate all the numbers in the list to find the max value in the
given list
Answers:
a. Number of operation can be expressed as f(n) = n where n is the number of elements in the list
b. for n =10 the algorithm loops 10 times so the number of
operations will be 10
c. the number of operation excluding the loop will be n since
we are comparing n with max 'n' times
d. time complexity or Big(O) is Big(O)=n
Question 4 CLO3 The following Python script implements an algorithm to find and prints the max value in a list of values. MAX 0 def MaxVal (Ist): for i in Ist: if( MAX < i): MAX = i return (MA...
Question 18 CLO3 Analyze the following code and answer the questions that follow def F(n): If n <= 1: return n else: return F(n-1)+F(n-2) for i in range (n) print (F(i)) Result: 0 1 1 2 3 5 8 13 a. Write number of operations as a function when the code is execute b If n 7, what is the total number of operations? c. What is the complexity of the algorithm behind the code? (2 Marks) (2 Marks) (1...
You need not run Python programs on a computer in solving the following problems. Place your answers into separate "text" files using the names indicated on each problem. Please create your text files using the same text editor that you use for your .py files. Answer submitted in another file format such as .doc, .pages, .rtf, or.pdf will lose least one point per problem! [1] 3 points Use file math.txt What is the precise output from the following code? bar...