All Topics  
Iteration

 

   Email Print
   Bookmark   Link

 

Iteration



 
  Iteration means the act of repeating.

Mathematics

Iteration in mathematics may refer to the process of iterating a function
Iterated function

In mathematics, iterated functions are the objects of deep study in computer science, fractals and dynamical systems. An iterated function is a function which is function composition with itself, ad infinitum, in a process called iteration....
, or to the techniques used in iterative method
Iterative method

In computational mathematics, an iterative method attempts to solve a problem by finding successive approximations to the solution starting from an initial guess....
s for solving numerical problems.

Computing

Iteration in computing is the repetition of a process within a computer program
Computer program

Computer programs are Instruction for a computer. A computer requires programs to function. Moreover, a computer program does not run unless its instructions are executed by a Central processing unit; however, a program may communicate an Algorithm#Formalization of algorithms to people without running....
. It can be used both as a general term, synonymous with repetition, and to describe a specific form of repetition with a mutable state.

When used in the first sense, recursion
Recursion

Recursion, in mathematics and computer science, is a method of defining Function in which the function being defined is applied within its own definition....
 is an example of iteration, but typically using a recursive notation, which is typically not the case for iteration.

However, when used in the second (more restricted) sense, iteration describes the style of programming used in imperative programming languages. This contrasts with recursion, which has a more declarative approach.

Here is an example of iteration, in imperative pseudocode
Pseudocode

Pseudocode is a compact and informal high-level description of a computer programming algorithm that uses the structural conventions of some programming language, but is intended for human reading rather than machine reading....
:

var i, a := 0// initialize a before iteration for i from 1 to 3 print a // the number 6 is printed

In this program fragment, the value of the variable i changes over time, taking the values 1, 2 and 3. This changing value—or mutable state—is characteristic of iteration.

Iteration can be approximated using recursive techniques in functional programming languages. The following example is in Scheme. Note that the following is recursive (a special case of iteration) because the definition of "how to iterate", the iter function, calls itself in order to solve the problem instance. Specifically it uses tail recursion
Tail recursion

In computer science, tail recursion is a special case of Recursion_ in which the last operation of the function, the tail call, is a recursive call....
, which is properly supported in languages like Scheme so it does not use large amounts of stack space. ; sum : number -> number ; to sum the first n natural numbers (define sum (lambda (n) (if (and (integer? n) (> n 0)) (let iter ([n n] [i 1]) (if (= n 1) i (iter (- n 1) (+ n i)))) ((assertion-violation 'sum "invalid argument" n)))))

An iterator
Iterator

In computer science, an iterator is an object that allows a programmer to traverse through all the elements of a Collection , regardless of its specific implementation....
 is an object that wraps iteration.

Project management

Iterations in a project context may refer to the technique of developing and delivering incremental components of business functionality. This is most often associated with agile software development
Agile software development

Agile software development is a group of software development methodologies that are based on similar principles. Agile methodologies generally promote a project management process that encourages frequent inspection and adaptation, a leadership philosophy that encourages teamwork, self-organization and accountability, a set of engineering be...
, but could potentially be any material. A single iteration results in one or more bite-sized but complete packages of project work that can perform some tangible business function. Multiple iterations recurse to create a fully integrated product. This is often compared with the waterfall model
Waterfall model

The waterfall model is a sequence development process, in which development is seen as flowing steadily downwards through the phases of Conception, Initiation, Analysis, Design , Construction,Integration and software maintenance....
 approach.

See also

  • Iterator
    Iterator

    In computer science, an iterator is an object that allows a programmer to traverse through all the elements of a Collection , regardless of its specific implementation....
  • For loop
    For loop

    In computer science a for loop is a programming language statement which allows code to be repeatedly execution . A for loop is classified as an iteration statement....
  • While loop
    While loop

    In most computer programming languages, a while loop is a Control flow statement that allows code to be executed repeatedly based on a given Boolean datatype condition....
  • Iterative and incremental development
    Iterative and incremental development

    Iterative and Incremental development is a cyclic software development process developed in response to the weaknesses of the waterfall model. It starts with an initial planning and ends with deployment with the cyclic interaction in between....
  • Iterated function
    Iterated function

    In mathematics, iterated functions are the objects of deep study in computer science, fractals and dynamical systems. An iterated function is a function which is function composition with itself, ad infinitum, in a process called iteration....