Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

java recursion definition?

I don't know where to begin on this question. I'm honestly not really sure what it's asking me to do.

public static int p(int x){

if(x < 3){

return x;

}

else {

return p(x - 1) * p(x - 3);

}

}

Let m(x) be the number of multiplication operations that the execution of p(x) performs.

a. write a recursive definition of m(x).

b. prove your answer to part a is correct using mathematical induction.

I don't want the answers, I want to understand how to do this on my own. Can someone give me an example or some help?

2 Answers

Relevance
  • 10 years ago
    Favorite Answer

    Its returning a product of corresponding terms of 2 A.P series one with common diff. =1 and the other with common diff.=3 till the term in the 2nd series starting with x and terminates when it reaches a min. value of 3.

  • cave
    Lv 4
    4 years ago

    A recursive function is one that calls itself as portion of the function. sillyExample(int x) { return x + sillyExample(x+a million); } See how this methodology calls itself? If x began out as 0 then the 1st recursion could be something like: 0 + ( 0 + a million)... now x might return to sillyExample as a million and the completed technique might proceed: a million + ( a million + a million )... be conscious: this sillyExample will run perpetually as there is no longer something to get away of the recursion. in case you attempt to run something like this your compiler could capture it as an blunders, if no longer the convey mutually will run till your device crashes. To make this a splash greater useful you may characteristic a fashion out of the recursion: sillyExample(int x) { if ( x==10) { return 10; } else { return x + sillyExample(x+a million); } } in many circumstances recursive purposes count quantity all the way down to a million or 0. Given an x then: return x * sillyExample(x-a million); the place: if(x==0) { return 0; } stable success... playstation Please forgive the obtuse formating compelled via the solutions style.

Still have questions? Get your answers by asking now.