Algorithmic Problem Solving: Algorithmic Problems Algorithms Algorithm A Set of Instructions
Algorithmic Problem Solving: Algorithmic Problems Algorithms Algorithm A Set of Instructions
In computing, we focus on the type of problems categorically known as algorithmic problems, where their solutions are expressible in the form of algorithms. An algorithm is a well-defined computational procedure consisting of a set of instructions, that takes some value or set of values, as input, and produces some value or set of values, as output. In other words, an algorithm is a procedure that accepts data, manipulate them following the prescribed steps, so as to eventually fill the required unknown with the desired values(s).
Input Algorithm Output
Recipe (software)
Ah-gong bah-kut-teh
The modern Euclidean algorithm to compute gcd (greatest common divisor) of two integers is often presented as followed:
Characteristic of an Algorithm
What makes an algorithm an algorithm? There are four essential properties of an algorithm. 1. Each step of an algorithm must be exact. 2. An algorithm must terminate. 3. An algorithm must be effective. 4. An algorithm must be general.
An algorithm should also emphasise on the whats, and not the hows, leaving the details for the program version.
Process box
Decision box
Yes
Yes
Yes
max num
Control Structures
The pseudo-code and flowchart in the previous section illustrate the three types of control structures. They are: 1. Sequence 2. Branching (Selection) 3. Loop (Repetition) These three control structures are sufficient for all purposes.
ave
temp
/* Display output */ printf ("The level 1 is %6.3f\n", level1); printf ("The level 2 is %6.3f\n", level2); printf ("The level 3 is %6.3f\n", level3); printf ("The index is %6.3f\n", index);
Problem analysis INPUT A collection of numeric values (number unknown). OUTPUT The number of values The mean (average) of the values