Clarification for Advancing Through an Array

#1

Hi, there is the following statement in the problem Advancing through an Array:

  • “For example, if A = (3,3,1,0,2,0,1), we iteratively compute the furthest we can advance to as 0, 3, 4, 4, 4, 6, 6, 7, which reaches the last index, 6.”

Please how can I get 0, 3, 4, 4, 4, 6, 7, 7. The book states we should perform i + A[i] to evaluate if we can reach the end of the array but if we do:

i = 0, 0 + A[0], 0 + 3 = 3
i = 1, 1 + A[1], 1 + 3 = 4
i = 2, 2 + A[2], 2 + 1 = 3

We cannot obtain the same result array. I am missing something because the furthest I am obtaining (3, 4, 3, …) has nothing to do with (0, 3, 4, 4, 4, 6, 7, 7), even the amount of items in the furthest array diverges from the original array A.

Could someone please point me in the right direction?

Btw I am working for more than one year over the book and I am still impressed by how good and clean the implementations are!

Regards
Marcos

0 Likes

#2

I know this is a long time coming, but I feel those examples are to give us an idea from the perspective of what the farthest variable reflects while iterating from one edge of the array to another.

0 Likes