An algorithm is a set of
ordered instructions based on a formal language with the following conditions:
An algorithm does not have to be deterministic - there are many random-based algorithms, e.g. QuickSort with selecting the pivot element randomly.
An algorithm can be expressed in many ways:
An algorithm can solve a class of problems. For example, both "sum 1 and 3" and "sum 4 and 5" are problems in the same class: "sum two integer numbers." Furthermore, a given class of problems can generally be solved by a variety of algorithms.
One important aspect of algorithm design is performance. For large datasets, a good algorithm may outperform a poor algorithm by several orders of magnitude. Algorithm performance is often rated with Big O or Θ notation, but one should be cautious with asymptotic notation, since big constants may be involved.
A key algorithm classification is known as Algorithm Complexity.
Another important step of algorithm design is proof of correctness. The algorithm should actually provide a correct result for any instance of the problem. We should always take care of all the conditions where the proposed algorithm might fail. This could be done using several techniques, For example, Model Checking, Assertion, Loop Invariant.
Additional resources on algorithms include: