Question: Consider the following algorithm: Algorithm Sum( m , n ) //Input: Two positive integers m and n where m n //Output: ? sum = 0

Consider the following algorithm:

Algorithm Sum(m, n)

//Input: Two positive integers m and n where m n

//Output: ?

sum = 0

for i=m to n do

for j=1 to i do

sum = sum + 8

end for j

end for i

return sum

What is the final result of sum? Show and determine the formula for the total number of additions (sum = sum + 8) performed by the algorithm.

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!