Consider the following recursive method Consider the followi

Consider the following recursive method:

Consider the following recursive method: What is run1 (4)? How many times does the method call itself?

Solution

it goes to else condition it will return 3+run1(3).

Then it will call function recursively

and run1(3) = 3+ run1(2)

run1(2)= 3+ run1(1)

run1(1) = 3+ run1(0)

run1(0)=3

replaacing all values

run1(1) = 6

run1(2) = 9

run1(3) = 12

run1(4) = 15

method calls itself 5 times

Consider the following recursive method: Consider the following recursive method: What is run1 (4)? How many times does the method call itself?Solutionit goes t

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site