184k views
4 votes
Here's another question!

What is some iterative programming structure uses?

1 Answer

1 vote

Answer

Often in an algorithm, a group of statements needs to be executed again and again until a certain condition is met, this is where we find the need for iteration.

The repeated execution of some groups of code statements in a program is called iteration.

In iteration control structures, a statement or block is executed until the program reaches a certain state, or operations have been applied to every element of a collection. This is usually expressed with keywords such as while, repeat, for, or do..until.

The basic attribute of an iteration control structure is to be able to repeat some lines of code. The visual display of iteration creates a circular loop pattern when flowcharted, thus the word “loop” is associated with iteration control structures. Iteration can be accomplished with test before loops, test after loops, and counting loops. A question using Boolean concepts usually controls how often the loop will execute.

Applications of Iteration

Iteration methodology has various applications in the programming world

  • Problem-solving in arrays, vectors, lists, strings, etc.
  • Problem-solving using Stack, Queue and Priority Queue
  • Bottom-up implementation of Dynamic Programming
  • Implementation of greedy algorithms
  • BFS traversal of tree and graph
  • Problem-solving using Hash Table and BST
  • Iterative Implementation of recursive code using stack

Iteration (Repetition) Control Structures

pseudocode: While

count assigned zero

While count < 5

Display "I love computers!"

Increment count

End

pseudocode: Do While

count assigned five

Do

Display "Blast off is soon!"

Decrement count

While count > zero

pseudocode: Repeat Until

count assigned five

Repeat

Display "Blast off is soon!"

Decrement count

Until count < one

pseudocode: For

For x starts at 0, x < 5, increment x

Display "Are we having fun?"

End

User Geoff Hackworth
by
4.4k points