Loops
New Terminology (review of
past terminology)
- loop control variable(s)
- One or more variables whose
value(s) determine how long the
loop will continue.
- sentinel (sentinel value)
- A value which is used to
stop (or continue) loop execution.
- flag
- A boolean value that flags
the end condition of a loop
execution
- accumulator
- A variable that serves to
accumulate a series of values.
Usually used in summation, but may be used for any repeated
operation.
- initialization
- For loops, this is the place
where we set-up one or more
variables that will be used to control loop execution.
- decision
- For loops, this determines
how long the loop will continue
to execute.
- update
- For loops, this step changes
the loop control variables to
approach the ending condition.
- body
- For loops, this is the code
that may repeatedly execute.
- off-by-one error
- A looping error in which the
control condition causes the
loop to execute either one time too many or one time too few.
- infinite loop
- A looping error in which the
control condition is never
reached
and the loop executes forever until killed by the operating system or
the user.
- nested loops
- Loops contained within other
loops. Some types of
problems lend themselves to nesting.
- interface
- The connection between a
driver (or calling) program and
the services that it uses
Java Specific Terms
- while loop
- A precondition loop in java
- do while loop
- A post condition loop in java
- for loop
- A precondition, counting
loop in java
- javadocs
- The documentation that is
produced from a program with
"self documenting" comments
Class notes
- PopSong.java
- Stars.java
- Stubs/Drivers - GCD_Square.java
Driver.java
- Examples of:
- Accumulator
- Sentinel value
- Flag
- Off by one
error
- Infinite loop
- Matrix loop
(how many times does the body execute?)