A missing neighbour is not zero
transcript
A grid table reads the cell above. On the first row, it does not exist. A quick answer is to read it as zero. That answer is wrong. What should the code read?
Take the grid minus one, zero, zero, zero. Reading a missing cell as zero returns zero. A real total can be below zero. Skipping the missing cell returns minus one.
Skip a cell that does not exist. Do not read it at all. For a maximum, start from a very low number. For a minimum, start from a very high number.
Only the start begins from zero. Every other cell starts very low. Then it takes the best neighbour that exists. The last cell is minus one.
Zero is not nothing. It can beat a real total. Skip the missing cell, and start very low. Then no real total is beaten by nothing at all. Full breakdown in the lecture.