Concept of Algorithm

Properties/Characteristics of a good algorithm

For an algorithm to be valid and executable by a computer, it must possess five key properties. These properties ensure the algorithm is reliable, predictable, and effective.

The Five Essential Properties

1. Finiteness (Termination): The algorithm must terminate after a finite number of steps. It cannot run forever.

Why it matters: An infinite loop is useless for solving a problem. The computer must eventually stop and produce a result.

Example: An algorithm to find the smallest number in a list will check each item once and then stop. An algorithm that says "repeat step 2 forever" violates finiteness.

2. Definiteness (Unambiguousness): Each step of the algorithm must be precisely defined and clear. There should be no room for ambiguity or multiple interpretations.

Why it matters: A computer cannot make guesses or assumptions. Every instruction must be exact.

Example: The step "Add a pinch of salt" is ambiguous. A definite step is "Add 5 grams of salt." In programming, this means every statement (like x = y + z) has a single, clear meaning.

3. Input: An algorithm has zero or more well-defined inputs. These are the values supplied to the algorithm before it begins.

Why it matters: Inputs provide the data the algorithm will process. An algorithm without input typically just produces a constant output.

Example: An algorithm for sorting requires an input list of numbers. An algorithm to calculate pi might have no inputs.

4. Output: An algorithm must have one or more well-defined outputs, which have a specified relation to the inputs.

Why it matters: The output is the solution to the problem. An algorithm without an output has not solved anything.

Example: The sorting algorithm must output the sorted list. A search algorithm must output the position of the item or a "not found" message.

5. Effectiveness (Feasibility): Every operation in the algorithm must be basic enough that it can be done exactly and in a finite amount of time. The steps must be "computable."

Why it matters: The algorithm must be practically executable with the available resources.

Example: "Find the largest prime number" is not effective because there is no largest prime the task is infinite. However, "Find the largest prime number less than 100" is effective because the steps (checking divisibility for numbers up to 100) are basic and finite.