Top

Part of algorithm which is repeated for fixed number of times is classified as

Share:
Q. Part of algorithm which is repeated for fixed number of times is classified as:
  1. iteration 
  2. selection 
  3. sequence 
  4. reverse action
Answer: Iteration

Iteration is the repetition of a mathematical or computational procedure applied to the result of a previous application, typically as a means of obtaining successively closer approximations to the solution of a problem.

Part of an algorithm which is repeated for the fixed number of times is classified as Iteration. In this, a set of instructions are repeated again and again. In computer programming, a loop is a kind of iteration in which instructions sequence is executed repeatedly. Each iteration starts with the end of previous one.
A recursive algorithm is one that invokes (makes reference to) itself repeatedly until a certain condition (also known as termination condition) matches, which is a method common to functional programming. Iterative algorithms use repetitive constructs like loops and sometimes additional data structures like stacks to solve the given problems.

Some problems are naturally suited for one implementation or the other. For example, towers of Hanoi is well understood using recursive implementation. Every recursive version has an equivalent (but possibly more or less complex) iterative version, and vice versa.

No comments