¡GoConqr estrena diseño! Cuéntanos qué te parece.

Fichas

Recursion

Ariana Parr Computer Science A level Inglés 7 fichas

Fichas del conjunto (7)

  1. 1What is recursion?When a subroutine (often a function) can call itself within its own subroutine. This means that each recursion will create a new copy of the function and remember all of the values that each function contains
  2. 2How does recursion work?Every time a recursive function calls itself, the process has to remember where it was in the program before it jumps to the new call, so it knows where to return to afterwards. This means that each recursion creates a new copy of the function but still remembers the previous versions of the function. It also has to remember the values of all of the variables because they are local to the function. This is done using stacks.
  3. 3What is the difference between recursion and iteration?Iteration is when the same block of code is repeated until a specified condition has been met.
    Recursion is when the same subroutine is called (copied) repeated until a specified condition has been met.
  4. 4What must a recursive function contain?- a stopping condition
    - it must call itself
    - a stopping condition that is reachable after a countable amount of time
  5. 5what are the benefits of recursion over iteration?- more natural to read
    - quicker to write/ less lines of code as some functions are naturally recursive
    - suited to certain problems
    - can reduce the size of a problem with each call.
  6. 6what are the drawbacks of recursion rather than iteration- can run out due to too many calls causing it to crash
    - more difficult to trace/follow as each frame on the stack has its own set of variables
    - requires more memory than the equivalent iterative algorithm
    - usually slower than iterative methods.
  7. 7why is recursion more memory intensive?- each recursive call stores the current state on the stack and creates a new variable. It has to remember the state of all the variables for all of the called functions
    - iteration uses the same variables

Información

Descripción
A level (Unit 2 - Topic 2) Computer Science Fichas sobre Recursion, creado por Ariana Parr el 20/02/2022.
Creado por
Ariana Parr
Visitas
0
Valoración

Escríbenos

¿Sobre qué es tu mensaje?

¿Qué te parece el nuevo diseño?

¿Te gusta?