Results 1 to 11 of 11
Like Tree2Likes
  • 2 Post By JosAH

Thread: can anyone help me out with this problem?

  1. #1
    sawpbianca is offline Member
    Join Date
    Apr 2012
    Posts
    1
    Rep Power
    0

    Default 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)?

  2. #2
    mwr1976 is offline Senior Member
    Join Date
    Oct 2011
    Posts
    106
    Rep Power
    0

    Default 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?

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,404
    Rep Power
    20

    Default 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.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,404
    Rep Power
    20

    Default Re: can anyone help me out with this problem?

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,651
    Blog Entries
    7
    Rep Power
    21

    Default Re: can anyone help me out with this problem?

    Quote Originally Posted by DarrylBurke View Post
    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.
    Are 'svo' and 'sawpbianca' one and the same person? Their IP address came from the same host ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  6. #6
    svo
    svo is offline Member
    Join Date
    Apr 2012
    Posts
    9
    Rep Power
    0

    Default 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

  7. #7
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,651
    Blog Entries
    7
    Rep Power
    21

    Default Re: can anyone help me out with this problem?

    Quote Originally Posted by svo View Post
    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
    Fubarable and sawpbianca like this.
    cenosillicaphobia: the fear for an empty beer glass

  8. #8
    svo
    svo is offline Member
    Join Date
    Apr 2012
    Posts
    9
    Rep Power
    0

    Default 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

  9. #9
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: can anyone help me out with this problem?

    Quote Originally Posted by svo View Post
    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
    Java Code:
    doNotHelpList.add(svo);
    With Regards,
    Fubarable.

  10. #10
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,651
    Blog Entries
    7
    Rep Power
    21

    Default Re: can anyone help me out with this problem?

    Quote Originally Posted by svo View Post
    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
    cenosillicaphobia: the fear for an empty beer glass

  11. #11
    svo
    svo is offline Member
    Join Date
    Apr 2012
    Posts
    9
    Rep Power
    0

    Default Re: can anyone help me out with this problem?

    I don't need help. Throw Error Exception.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •