Ways to express solution algorithm
There are numerous ways to express the algorithm which provides a solution to given problem; it can be expressed as flowchart, pseudo code, natural language, programming language or drakon-chart. Natural language is used to make an algorithm easy to understand but while solving complex problems it may create ambiguity and becomes a lengthy procedure. Programmers usually recommend flowcharts, pseudo codes or drakon-charts to express algorithm as these methods provide structured way and high-level description. Every solution algorithm must provide detailed implementation description that includes problem statement, list of entities used, logic and other resources to be used.
Checking the correctness of an algorithm
Solution algorithm is declared to be correct based on functional and specification correctness; functional correctness identifies the working of input and the expected output. Specification based correctness checks the overall behavior of the algorithm based on the system in which it is going to be implemented. Algorithm must be checked for total correctness that means it produces the correct results for the given inputs and it gets terminated precisely. Checking of solution algorithm depends on the correctness of statements to be proven, the assumptions and the reasoning logic. The expected output of any algorithm is based on the series of instructions, the given inputs and the state or behavior of variables used in the algorithm. Usually most of the computations are based on mathematical expressions while solving a problem so induction method can be used as an efficient tool to prove the correctness of solution algorithm. Mathematical induction works well where loops, iterations or recursions are used to solve a problem
Generic or specific solution
Algorithm must be checked whether it provides a generic solution or a specific solution; that means the solution algorithm can give exact specific solution to the given problem or it results in simple general solution. For example, an algorithm is written for calculating the area of circle by giving radius values; it is then identified that the algorithm can calculate the area of circle by giving all range of radius values as input or just particular values. If the solution algorithm provides exact results for all range of values, it means it is correct otherwise it is reviewed. Formal semantics and set of rules defined are also identified while checking the correctness of solution algorithm. Semantics defines the meaning of technical specifications and the inference rules represents that the logic of the algorithm works correctly. Validation of semantics is being carried out in this stage to determine the feasibility of the solution algorithm with programming language code.