I have this question for a homework assignment.
Consider the following algorithm segment: for i=1 to n for j=i to n X=X+5; What is the number of additions (+) performed by this code segment? Prove your answer.
It clearly wants you to create and solve a recurrence relation based on this algorithm although I have no idea how to convert the algorithm into a recurrence relation that can then be solved.
I know that the first for loop (i) will run (n-1) times, but I don't understand how to generalize how many times the second for loop will run given that it will run a different number of times each time the first loop runs given that i will have been incremented.
I'm not looking for a solution to this question but rather the method for converting this type of algorithm, into a general case that can then be calculated.