Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
Recursion question
Old
cedricdosss
Junior Member
 
Status: Offline
Posts: 10
Join Date: Nov 2012
Default Recursion question - 11-30-2012, 06:12 AM

7. Which of the following is best describes “recursion”:

a. It is a loop identified during programming by the reserved word: RECURSION.
b. It is a programming technique.
c. It is a complex technique that should be avoided.
d. It is similar to a random number generator.
e. It is most like an infinite loop.

I think the right answer is B


10. In Chapter 7, Table 7-2, of “Starting Out with Alice”, there are a number of functions associated with Lists. Suppose that you used the ‘size of list’ function on a list and it returned a value of 10. The list function “First item from list” returns the first item in the list. As noted, it is in position 0. Using the function “Last item from list”, then would return the last item. What “position” is this last item?
a. Zero
b. One
c. Nine
d. Ten




4. Which one of the following statements is true:
a. A class cannot contain more than one method.
b. The color red is an example of a method.
c. Methods are part of a class.
d. Methods in one class cannot call methods of another class.
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 11-30-2012, 01:00 PM

We can't help you with homework by simply telling you the right answers, but we can help you figure it out.

For the first question, do you know what recursion is? It's when a method calls itself. Think about what that means.

Second question: You should be able to figure that out yourself. If you're having trouble with simple questions like that, you're either not trying, or you need help from the teacher. Ask him/her after class if you can have some things explained to you. I'm really not trying to be a jerk here, I'm just trying to keep you from burning yourself later on.

Third question: Two of the options are ridiculous and can be eliminated immediately. To find which of the two remaining options is right, you need to know what a class is, and what kinds of things classes can do.


(')>
   
Reply With Quote
Old
nitp18
Junior Member
 
Status: Offline
Posts: 2
Join Date: Jan 2013
Location: Warsaw, PL
Default 01-24-2013, 02:55 AM

x2495iiii

tell answers


http://interdomus.pl/interdomus/kuchnie

http://www.admico.pl/zarzadzanie-nieruchomosciami

Last edited by nitp18; 02-19-2013 at 04:42 AM.
   
Reply With Quote
Old
Brettlee
Junior Member
 
Status: Offline
Posts: 14
Join Date: May 2013
Location: New York
Default 06-07-2013, 06:17 AM

I think that the right answer is "d". Am I right??
   
Reply With Quote
Old
hollyrbraswell
Junior Member
 
Status: Offline
Posts: 4
Join Date: Jan 2016
Default 01-29-2016, 11:45 PM

i know this much only recursion is the repeated application of a recursive procedure or definition.
   
Reply With Quote
Recursion
Old
chickentree
Super Moderator
 
Status: Offline
Posts: 250
Join Date: Dec 2012
Location: Frosno, Ca
Default Recursion - 01-31-2016, 04:20 PM

In order to forget recursion,you must first forget recursion.
Is a toung in cheek way to remember it.

On the one hand recursion can be an elegant solution to a complex problem while on the other hand, it's execution can be slow and resource intensive (using lot of memory, disk space or both.)

Basically, if you can beappreak a problem's solution into smaller and easier to solve problems, you can use recursion to solve it. At the same time it should probably be made clear that any recursive method can be rewritten in a non-recursive way.
A silly example:
Code:
count(int)
  if(int>0)
    return(count(int-1)+1) // the call that makes this a recurrence 
  else
    return(0)  // the condition that cause the recursion to end.

So count(3) would result in:
  count(3)
    return(count(2))+1
      return count(1)+1
        return(count(0)+1)
          return(0)
Which would call itself 4 times until the argument was 0 and then begin ending each recursive step back up the call chain returning 0, 1 , 2, and finally 3. Note that while the function is recurring, none of the previous calls can end. This is what uses up resources.

Hope this helped,


Mark Henwood
mhenwood@ieee.org
   
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.