INTRODUCTION/RECURSION Flashcards
is a procedure to accomplish a specific task.
ALGORITHM
It must solve a general, well-specified problem.
ALGORITHM
typically involves input data, a set of rules or constraints, and a desired output.
ALGORITHMIC PROBLEM
WHAT IS A GOOD ALGORITHM
CORRECT
EFFICIENT
EASY
is a way/process of defining a function to call itself, using
smaller inputs.
RECURSION
Every iterative procedure can be converted to a recursive
function.
RECURSION
Algorithms are naturally recursive.
RECURSION
A function that uses recursion is called
RECURSIVE FUNCTION
calls itself with smaller input values
and returns the result for the current input by carrying out
basic operations on the returned value for the smaller
input.
RECURSIVE ALGORITHM
COMPONENTS OF RECURSIVE ALGORITHM
BASE CASE
RECURSIVE CASE
RECURSIVE CALL
RETURN VALUE
This is the condition that terminates the recursive calls and
returns a result.
BASE CASE
It is usually the simplest form of the problem that can be
solved without further recursion.
BASE CASE
This is the part of the algorithm that calls itself with a
smaller or simpler instance of the same problem.
RECURSIVE CASE
makes progress towards the base case by breaking down the problem into smaller sub-problems.
RECURSIVE CASE
This is the actual call to the function itself with modified
input parameters.
RECURSIVE CALL