Question: nput: Some value n > 0 Output: A summation based on the value of n r = 0 ; for i = 1 to n

nput: Some value n >0
Output: A summation based on the value of n
r =0;
for i =1 to n do
for j =1 to i do
for k = j to i+j do
r = r +1;
return r
What value is returned by this algorithm, expressed as function of n? What is the O(n) of this
algorithm? Justify your answer

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!