Question: The objective of this programming assignment is to implement in your preferred * language an algorithm A to compute the sum _ ( i =
The objective of this programming assignment is to implement in your preferred language an algorithm A to compute the sum inaxi where a and x are a real numbers x We are interested in exploring the relationship between the time complexity and the real timewall time For this exploration, you will collect the execution time Tn of Algorithm A as a function of n and plot Tngn Tngn and Tngn on different graphs. Finally, discuss your results: use the plots you will build to determine and justify the time complexity of TnHint: analyze ahead the time complexity Tn of ComputeSumPowers to predict the expected shapes of Tngn Tngn and Tngn
Algorithm A
ComputeSumPowersaxn
inputs: x is a real number with x a is a real number. n is an integer n
output: a real number equal to inaxi
sum
prod x
for i to n
sum sum prod
prod prod x
return asum a
Suppose that for n very large, TnKgn where K is a constant.
i point What would then the values of Tngn Tngn and Tngn be respectively? just replace Tn with Kgn
and simplify the expression you get
answer here
ii points Based on the expressions obtained in the previous question, what would then the shapes of the plots Tngn Tngn and Tngn be respectively?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
