I was wondering what the loop invariant would be for the loop present in lines 4 - 6 of this code and how to prove it during intialization, mantience, and termination.
def cut_rod(p, n):
if n == 0:
return 0
q = -inf
for i = 1 to n:
q = max(q, p[i] + cut_rod(p, n-i))
return q
I wasn't really sure where to start here so some insight would be great :)