Functions as abstraction mechanisms
-Abstraction- hides detail, allowing person to view many things as one thing
-Example of everyday tasks: doing my laundry
Functions eliminate__
redundancy
Functions hide__
complexity
- a function call expresses the idea of a process to the programmer w/o forcing him/her to wade through the complex code that realizes that idea
Functions Support ___ with Systematic Variations
Functions support the ___
Top-down design
Structure chart
recursive design
the process of decomposing a problem into subproblems of exactly the same form that can be solved by the same algorithm
recursive function
a function that calls itself
-To prevent function from repeating itself indefinitely, it must contain at least one selection statement
base case
the condition in a recursive algorithm that is tested to halt the recursive process
selection statement
examines base case to determine whether to stop or to continue with another recursive step.
recursive definition
-a set of statements in which at least one statement is defined in terms of itself.
-consists of equations that state what a value is for one or more
base cases and one or more recursive cases
infinite recursion
-in a running program, the state that occurs when a recursive method cannot reach a stopping state
-arises when programmer fails to specify base case or to
reduce size of problem in a way that terminates the recursive process
PVM reserves an area of memory for the ____
call stack
For each call of a function, the PVM must allocate on the call stack a _____
stack frame
A stack frame contains____
When a call returns, ________ is used to locate the next instruction, and stack frame is deallocated
return address
T or F: Amount of memory needed for a loop grows with the size of the problem’s data set
F: Amount of memory needed for a loop does not grow with the size of the problem’s data set
namespace
the set of all of a program’s variables and their values
- can be controlled with good design principles
____ and _____ receive their values as soon as they are introduced
____ behave like a variable and are introduced in a function or method header
method names
a method reference always uses an object followed by a dot and the method name
ie:
sentence.split()
scope
the area of a program text in which the value of a variable is visible
Scope of temp variables