GoConqr has a new look! Let us know what you think.

Flashcards

Recursion

Nathan Hunsdale Programming 2 Masters of Science English 21 cards

Cards in this deck (21)

  1. 1Recursion What is a recursive method?A method that calls itself
  2. 2Recursion When a recursive method is called to solve a problem, it is actually only capable of solving the _____ cases aka _____ casesWhen a recursive method is called to solve a problem, it is actually only capable of solving the simplest cases aka base cases
  3. 3Recursion If the method is called with a base case, it returns a _____result
  4. 4Recursion If a method is called with a complex problem it...divides the problem into 2 conceptual pieces
  5. 5Recursion What are the 2 conceptual pieces?A piece that the method knows how to solve
    A piece that it does NOT know how to solve
  6. 6Recursion To make recursion possible, the latter piece must resemble the original problem, but be a slightly _____ or _____ version of itTo make recursion possible, the latter piece must resemble the original problem, but be a slightly simpler or smaller version of it
  7. 7Recursion This new problem now looks like the original problem, and the method calls a fresh copy of itself to work on the smaller problem; this is called a _____ _____recursive call
  8. 8Recursion Recursive Step This normally includes a _____ _____, because its result will be combined with the portion of the problem the method knew how to solve to form a result that will be passed back to the original callerreturn statement
  9. 9Recursion Termination Each time the method calls itself with a simpler version of the original problem, the sequence of smaller and smaller problems must converge on a _____ _____.Base Case
  10. 10Recursion Termination When the method recognizes the base case, it returns the result to the _____ _____ of the methodprevious copy
  11. 11Recursion Termination A sequence of results ensues until the _____ _____ _____ returns the final result to the calleroriginal method call
  12. 12Recursive methods Factorial A Factorial is the product of an _____ and all the _____ below it e.g....integer
    4! = 4x3x2x1 = 24
  13. 13Recursion What is a Base Case? e.g.The point at which the method stops calling itself
    e.g
    if(n == 1){
    return 1;}
  14. 14Iteration vs Recursion Any problem that can be solved recursively can also be solved _____iteratively
  15. 15Iteration vs Recursion Which method is preferred and why?Recursive is NORMALLY preferred
    - The recursive more naturally mirrors the problem
    - Program is easier to understand and debug
  16. 16Iteration vs Recursion Which has fewer lines of code?Recursion
  17. 17Recursion What is overhead?The resources required to set up an operation
  18. 18Recursion Negative Aspects With every recursive call it invokes method _____ which can be expensive in terms of _____ _____ and _____ _____With every recursive call it invokes method overhead which can be expensive in terms of processor time and memory space
  19. 19Recursion When should you avoid using it?In situations which require high performance
  20. 20Recursion It takes time and consumes additional _____memory
  21. 21Recursion A common use for recursion is _____ and _____ listssorting and searching

Information

Description
Masters of Science Programming 2 Flashcards on Recursion, created by Nathan Hunsdale on 31/05/2014.
Created by
Nathan Hunsdale
Views
24
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?