Grundlagen zu Algorithmen

Programme, die auf Computern ausgeführt werden, beruhen auf Algorithmen.

definition

Ein Algorithmus ist eine schrittweise Handlungsanweisung in natürlicher Sprache, welche dann in ein Programm (also eine Sprache, die vom Computer verstanden wird) übertragen wird. Ein Algorithmus ist eine Vorschrift zur Verarbeitung von Daten.

Ein Algorithmus muss folgende Kriterien erfüllen (Rautenstrauch & Schulze, 2003, S. 55):

Ein Algorithmus kann in natürlicher Sprache, in strukturierter Sprache oder formal notiert sein.

example

Ein Algorithmus in natürlicher Sprache

First, place the oil pan underneath the oil plug of your car. Next, unscrew the oil plug and drain the oil. Now, replace the oil plug. Once the old oil is drained, remove the oil cap from the engine and pour in 4 quarts of oil. Finally, replace the oil cap on the engine.

Ein Algorithmus in strukturierter Sprache

  1. Place the oil pan underneath the oil plug of your car.
  2. Unscrew the oil plug.
  3. Drain oil.
  4. Replace the oil plug.
  5. Remove the oil cap from the engine.
  6. Pour in 4 quarts of oil.
  7. Replace the oil cap.

Ein formaler Algorithmus in C++

a = 1;
b = 0;
while (a <= 10)
{
b = b + a;
a++;
}
cout << b;

Quelle: http://courses.cs.vt.edu/~csonline/Algorithms/Lessons/index.html