# can anyone help me out with this problem?

• 04-08-2012, 10:40 AM
sawpbianca
can anyone help me out with this problem?
1. This problem is based on an analysis of the following code segment:

public int multiply( int n )

{

if (n == 0)

return 1;

else if (n % 2 ==1)

return n;

else

return n * multiply( n - 2);

}

a) What is the output of the method call multiply(8)? (Hint: make a program with comments and submit it or just perform a code analysis!)

b) What do you notice about the bolded text in regards to programming? What is this programming concept called? Explain this concept. Back up your explaination by writing out each step in the code. Be prepared to discuss.

2. This problem is based on an analysis of the following code segment:

public in f1( int x )

{

if ( x == 0 )

return 0;

else

return f2( x - 2 );

}

public in f2( int x )

{

if ( x == 1 )

return 1;

else

return f1( x + 1 ) + x;

}

a) What is the output of the code given the method call f1(5)?

b) Write out each step of the method call. In other words, explain the answer.

3. Consider the following code segment:

public int recur(int n)
{
if (n<=10)
return n * 2;
else
return recur(recur(n / 3));
}

a) What output is produced by the method call recur(27)?
• 04-08-2012, 10:43 AM
mwr1976
Re: can anyone help me out with this problem?
Sorry, no one here is going to do your homework for you. Do you have a specific question you need answered?
• 04-08-2012, 11:52 AM
DarrylBurke
Re: can anyone help me out with this problem?
http://www.java-forums.org/new-java/...-question.html

Why did you repeat the same question here, with something more tagged on? If there was something you didn't understand you should continue in the same thread.

db
• 04-08-2012, 11:52 AM
DarrylBurke
Re: can anyone help me out with this problem?
• 04-08-2012, 01:30 PM
JosAH
Re: can anyone help me out with this problem?
Quote:

Originally Posted by DarrylBurke
http://www.java-forums.org/new-java/...-question.html

Why did you repeat the same question here, with something more tagged on? If there was something you didn't understand you should continue in the same thread.

Are 'svo' and 'sawpbianca' one and the same person? Their IP address came from the same host ...

kind regards,

Jos
• 04-08-2012, 06:02 PM
svo
Re: can anyone help me out with this problem?
NO we are NOT one in the same person. I know who that is though. Our AP computer science teacher gave us this assignment over Spring Break and ENCOURAGED us to seek help in java forums... Kindly enough giving links to some supposedly 'helpful' ones. However, I found no help here.. or anywhere for that matter. My AP Barrons book did the trick. It makes more sense than all the baffouns here put together. Yet why our "ip address came from the same host" I don't know! But I'm sure as hell not retarded enough to make a second account to seek help from this forum...

thanks,
svo
• 04-08-2012, 06:16 PM
JosAH
Re: can anyone help me out with this problem?
Quote:

Originally Posted by svo
NO we are NOT one in the same person. I know who that is though. Our AP computer science teacher gave us this assignment over Spring Break and ENCOURAGED us to seek help in java forums... Kindly enough giving links to some supposedly 'helpful' ones. However, I found no help here.. or anywhere for that matter. My AP Barrons book did the trick. It makes more sense than all the baffouns here put together. Yet why our "ip address came from the same host" I don't know! But I'm sure as hell not retarded enough to make a second account to seek help from this forum...

I remember I helped you out with a similar (identical?) question, so your remark about not receiving any help in this forum at all is simply incorrect and aamof quite rude.

Jos
• 04-08-2012, 06:28 PM
svo
Re: can anyone help me out with this problem?
Indeed. Quite rude... Beating around the bush when someone is trying to actually learn something is not rude? I wasn't asking for an answer. I was simply asking for guidance in what to do as we had never even covered this topic in our class. I apologize if you found the truth rude but you can all sit here on your silly non-helpful forums while I go out and actually learn stuff. And Fubarable can keep going around being even MORE un-helpful sucking up to other un-helpful people. Have a wonderful day!

With regards,
SVO
• 04-08-2012, 06:35 PM
Fubarable
Re: can anyone help me out with this problem?
Quote:

Originally Posted by svo
Indeed. Quite rude... Beating around the bush when someone is trying to actually learn something is not rude? I wasn't asking for an answer. I was simply asking for guidance in what to do as we had never even covered this topic in our class. I apologize if you found the truth rude but you can all sit here on your silly non-helpful forums while I go out and actually learn stuff. And Fubarable can keep going around being even MORE un-helpful sucking up to other un-helpful people. Have a wonderful day!

With regards,
SVO

Code:

`doNotHelpList.add(svo);`
With Regards,
Fubarable.
• 04-08-2012, 06:38 PM
JosAH
Re: can anyone help me out with this problem?
Quote:

Originally Posted by svo
Indeed. Quite rude... Beating around the bush when someone is trying to actually learn something is not rude? I wasn't asking for an answer. I was simply asking for guidance in what to do as we had never even covered this topic in our class. I apologize if you found the truth rude but you can all sit here on your silly non-helpful forums while I go out and actually learn stuff. And Fubarable can keep going around being even MORE un-helpful sucking up to other un-helpful people. Have a wonderful day!

Plonk

Jos
• 04-08-2012, 06:43 PM
svo
Re: can anyone help me out with this problem?
I don't need help. Throw Error Exception. :(giggle):