1

Im going over the solution to a previous midterm of mine below, and i dont understand line 9 in the pseudo code. For the first iteration when s=1 and i=1, A[i] would equal 12, whixh would make C[i,s] equal to C[i-1,s]

But wouldnt C[i-1,s] throw an error since i would now be 0 (out of bounds?)

enter image description here

1 Answer 1

2

Line 9:

C[i,s] = C[i-1,s].

Note that in subproblem c you have already defined:

C[0,s] = 0 for all s.

So C[1-1, s] will return a 0.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.