Structured Programming Week 13: Recursion

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

dead or unreachable

In computer programming, ___ code is part of the source code of a program which can never be executed because there exists no control flow path to the code from the rest of the program.

base case

The ___ is the part of a calculation that can be solved without recursion. This stops the recursive function from continuing to call itself.

body

The ___ of a function is the set of statements that perform the function's operation.

formal

The list of parameters indicated in the function definition are called ___ parameters.

flow of execution

The order in which statements are executed in a program is referred to as the program's ___.

header

The very first line of a function definition is the function ___.

void

A(n) ___ function is a function that does not return a value to the part of the program that executed it.

library

A(n) ___ is a collection of precompiled routines that a program can use.

function

A(n) ___ is a collection of statements that performs a specific task.

stub

A(n) ___ is a dummy function that is called instead of the actual function it represents. It usually displays a test message acknowledging that it was called, and nothing more.

library

A(n) ___ is a package of code that is meant to be reused by many programs.

function, procedure, subroutine

A(n) ___ is a programming construct that allows a programmer to associate a given set of instructions with a specific name.

parameter

A(n) ___ is a special variable that holds a value being passed into a function.

local

A(n) ___ variable is defined inside a function and is not accessible outside the function.

global

A(n) ___ variable is defined outside all functions and is accessible to all functions in its scope.

overloading

Function ___ is a programming concept that allows programmers to define two or more functions with the same name as long as each of the functions has a unique signature.

recursive

A ___ function is one that calls itself.

definition

A function ___ contains the interface to the function as well as the statements that make up the function.

prototype

A function ___ eliminates the need to place a function definition before all calls to the function.

call

A function ___ is a statement that causes a function to execute.

return

A function can send a value to the part of the program that executed it. This value is called a(n) ___ value.

true

A problem can be solved with recursion if it can be broken down into successive smaller problems that are identical to the overall problem.

global

A(n) ___ constant is a named constant that is available to every function in a program.

true

Any problem that can be solved recursively can also be solved iteratively, with a loop. In fact, recursive algorithms are usually less efficient than iterative algorithms. This is because a function call requires several actions to be performed by the C++ runtime system. These actions include allocating memory for parameters and local variables and storing the address of the program location where control returns after the function terminates. These actions, which are sometimes referred to as overhead, take place with each function call. Such overhead is not necessary with a loop.

code block

Enclosing a group of statements inside a set of braces creates a(n) ___.

procedure, subroutine

In programming, a function is a named section of a program that performs a specific task. In this sense, a function is a type of [a] or [b]. Some programming languages make a distinction between a function, which returns a value, and a procedure, which performs some operation but does not return a value.

modular

Instead of writing one long program that contains all of the statements necessary to solve a problem, several small functions that each solve a specific part of the problem can be written. A program of this type is called a(n) ___ program.

arguments, actual parameters

Values that are sent to a function are called [a] (a.k.a. [b]).

local

Variables that are defined inside a function are called ___ variables.

static

Variables that are defined inside a function that remain in memory after the function has finished executing are called ___ variables.

passed by value

When a copy of an argument is passed to a function, it is said to be ___.

passed by reference

When a reference variable is used as a parameter, it is said that the argument is ___.

reference

When used as parameters, ___ variables allow a function to access the parameter's original argument. Changes to the parameter are also made to the argument.

driver code

__ is code that tests a function by simply calling it.

static

__ local variables exist for the lifetime of the program, even though their scope is only the function in which they are defined.

default

___ arguments are passed to parameters automatically if no argument is provided in the function call.

incremental development

___ involves writing and testing small portions of a program repeatedly until the program is complete.

direct

___ recursion is when a recursive function calls itself.

indirect

___recursion occurs when function A calls function B, which in turn calls function A. There can even be several functions involved in the recursion. For example, function A could call function B, which could call function C, which calls function A.


Kaugnay na mga set ng pag-aaral

Pharm 5: Administering Injections

View Set

EAQ Psych - Mental Health Disorders

View Set

Chapter 11 Consumer Behavior - attitudes

View Set

Industrial Electronics Chapter 7 [Servo Motors]

View Set