1.

consider the following function def f(m) :if m==0 return (0)else: return (m+f(m-1))​how will the function terminates

Answer»

It GIVES you the sum of the given number m, i.e. Σ(m), where m >= 0Explanation:The function is a recursive function with the termination condition that RETURNS 0. As a result, the output of the function would be, m+m-1+m-2+...1+0 -> Σm.However, if m < 0, this goes into an infinite recursion, this causing a stack overflow, in most of the COMPUTER language runtimes



Discussion

No Comment Found