Results 1 to 11 of 11
 04082012, 10:40 AM #1Member
 Join Date
 Apr 2012
 Posts
 1
 Rep Power
 0
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)?
 04082012, 10:43 AM #2Senior Member
 Join Date
 Oct 2011
 Posts
 106
 Rep Power
 0
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?
 04082012, 11:52 AM #3
Re: can anyone help me out with this problem?
You got good answers in your previous thread.
AP computer science question
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.
dbIf you're forever cleaning cobwebs, it's time to get rid of the spiders.
 04082012, 11:52 AM #4
Re: can anyone help me out with this problem?
Cross posted
AP computer science questions
dbIf you're forever cleaning cobwebs, it's time to get rid of the spiders.
 04082012, 01:30 PM #5
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 13,309
 Blog Entries
 7
 Rep Power
 20
 04082012, 06:02 PM #6Member
 Join Date
 Apr 2012
 Posts
 9
 Rep Power
 0
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
 04082012, 06:16 PM #7
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 13,309
 Blog Entries
 7
 Rep Power
 20
 04082012, 06:28 PM #8Member
 Join Date
 Apr 2012
 Posts
 9
 Rep Power
 0
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 nonhelpful forums while I go out and actually learn stuff. And Fubarable can keep going around being even MORE unhelpful sucking up to other unhelpful people. Have a wonderful day!
With regards,
SVO

 04082012, 06:38 PM #10
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 13,309
 Blog Entries
 7
 Rep Power
 20
Re: can anyone help me out with this problem?
Plonk
Joscenosillicaphobia: the fear for an empty beer glass
 04082012, 06:43 PM #11Member
 Join Date
 Apr 2012
 Posts
 9
 Rep Power
 0
Bookmarks