Not able to find recurrence relation

can you please help me to find the recurrence relation to this problem

  1. Construct a sum matrix S[R][C] for the given M[R][C].
    a) Copy first row and first columns as it is from M[][] to S[][]
    b) For other entries, use following expressions to construct S[][]
    If M[i][j] is 1 then
    S[i][j] = min(S[i][j-1], S[i-1][j], S[i-1][j-1]) + 1
    Else /If M[i][j] is 0/
    S[i][j] = 0
  2. Find the maximum entry in S[R][C]
  3. Using the value and coordinates of maximum entry in S[i], print
    sub-matrix of M[][]

why minimum is used to find s[i][j]

1 0 0
1 1 1
1 0 1

for ar[1][1] , what would you say the answer = 1 or 2
1, because ar[0][1] is 0 , so it doesn’t help .
If any of the three is 0, it wont help, so we take minimum

what if adjacent squares have non-negative values? we have to take maximum value

You won’t get negative values anywhere.

Yes take min for every box for all 3 adjacent nodes.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

I didn’t understand the intuition behind the recurrence relation

Okay, Have a look at this to get better understanding.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.