top of page

Recursion

  • Karla G
  • 28 mar 2015
  • 1 Min. de lectura
Recursion Defined

What is recursion? Sometimes a problem is too difficult or too complex to solve because it is too big. If the problem can be broken down into smaller versions of itself, we may be able to find a way to solve one of these smaller versions and then be able to build up to a solution to the entire problem. This is the idea behind recursion; recursive algorithms break down a problem into smaller pieces which you either already know the answer to, or can solve by applying the same algorithm to each piece, and then combining the results.

(by Sparknotes)

Looking for further information? Go to sparknotes, seriusly. This page explains it all:

http://www.sparknotes.com/cs/recursion/whatisrecursion/section1.rhtml

Now, a little example of recursion:

We all know what a factorial is, if not, go look for it and then continue.

Here is the pseudocode for developing a factorial :

function fact (n is a non-negative integer)

if n is 0 then

return 1 [by the convention that 0! = 1]

else

return factorial(n – 1) times n [recursively invoke factorial with the parameter 1 less than n]

end if

end function

Recursion is literally a function calling itselve n times until it get a result.

Here you can see how the pseudocode is executed for n=6

recursion.gif

References:

Sparknotes. (2015). What is Recursion?. 27 March 2015, de Sparknotes LLC Sitio web: http://www.sparknotes.com/cs/recursion/whatisrecursion/section1.rhtml

 
 
 

Comments


 THE ARTIFACT MANIFAST: 

 

This is a great space to write long text about your company and your services. You can use this space to go into a little more detail about your company. Talk about your team and what services you provide. Tell your visitors the story of how you came up with the idea for your business and what makes you different from your competitors. Make your company stand out and show your visitors who you are. Tip: Add your own image by double clicking the image and clicking Change Image.

 UPCOMING EVENTS: 

 

10/31/23:  Scandinavian Art Show

 

11/6/23:  Video Art Around The World

 

11/29/23:  Lecture: History of Art

 

12/1/23:  Installations 2023 Indie Film Festival

 FOLLOW THE ARTIFACT: 
  • Facebook B&W
  • Twitter B&W
  • Instagram B&W
 RECENT POSTS: 
 SEARCH BY TAGS: 

© 2023 by Karla Lugo. Proudly created with Wix.com

bottom of page