# Finding sequences in a binary matrix with recursion

Given a binary square matrix of order $$n$$. Can the problem of finding the longest sequence of 1's (horizontal or vertical) be solved with recursion?

I know how to solve the problem without recursion by iterating over the columns and rows, but was wondering it there is a solution using recursion.

• Can you define your problem in more detail? Also, what do you mean by solve with recursion? Oct 9, 2021 at 7:12
• Usually a solution not using recursion is thought to be better than one that uses recursion, if they both have the same time complexity. Oct 9, 2021 at 9:13
• If you know how to solve the problem without recursion then you also know how to solve it with recursion. Simply recurse as many times you desire and, once the desired depth of recursion is reached, solve the problem using your current strategy. That's probably not what you want but if the only constraint is to solve the problem "using recursion", then this approach formally satisfies the request. Oct 9, 2021 at 16:33