Recursion

  • Recursion is a is the process of repeadetly calling a function from within the definition of the function itsself

  • Advantages
    • it allows to repeat a process withouit using much code
    • it can be a elegant sollution to a problem
  • Disadvantages
    • if the process is not stopped this can result in the programm malfunctioning and the computer crashing becuase too much primary memeory is used
    • It can take loger than other methods
    • It can also be very tricky
Examples:
  • The fibbonaci sequence (1+1+2+3+5+8+13+21+34)
  • a Mirror facing another mirror (see left image)
  • Sierpinski Triangle (see right image)

recursion.jpg
A example of reccursion in real life: a mirror facing another mirror. Created by Johann Beleites

SierpinskiTriangle.png
A sierpinski triangle

Created by Daniel Gillo
Last Edited: 18/11/2010