Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need only explanations for (ii) and (iii), thank you. (b) Consider the following recursive algorithm multi(n,m). Algorithm multi(n, m) //Input: two integers n and m

image text in transcribed

Need only explanations for (ii) and (iii), thank you.

(b) Consider the following recursive algorithm multi(n,m). Algorithm multi(n, m) //Input: two integers n and m //Output: ? if n==1 return m else return m + multi(n-1, m) (i) Perform the box-trace of the algorithm for n=4, m=9. Specify the output. [3 marks] (ii) For which values of n and m will the algorithm fail to terminate? [2 marks] (iii) For values of n and m, for which algorithm terminates, what will be the value returned? Provide a brief explanation. [2 marks]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions