For your first algorithm,
if (i < m)
algo(n, m, i+1)
will basically call algo
for total of m * (m-1) / 2
times, each algo
has a O(n)
loop, so, the total complexity will be O(n * m ^ 2)
.
Or in other words, for the first algorithm, it's similar to T(i) = n + T(i-1)
, where i = 0, ..., m
.