Rules of writing algorithms

         algorithm contains troubleshooting steps. these steps can be written in any notation, provided easy to read and understand, because there is no notation in the book writing algorithms. each person can make the rules of writing and notation own algorithm. notation for the algorithm easily translated into a programming language notation, it should correspond with the algorithm notation notation of programming languages ​​in general.

Rules of writing algorithms

Each algorithm will always consist of 3 parts:

  • title (header)
  • dictionary
  • algorithm

In each section will be written if the comments on each section is written between curly braces {comment} example. Algorithmic notation is written between these marks will not be executed by the program.



Example:

Title
{Comments on algorithms such as the workings of the program, initial conditions and final condition of the algorithm}

Dictionary
{In this section, defined constant names, variable names, procedure names and function names}

Algorithm
{In this section algorithms are written. all written text not between curly braces will be sebagainotasi algorithm that will affect the truth of the algorithm}



TITLE (Header)
The title is the text of the algorithms used as a place to define the name by determining whether the text is a program, procedures, functions. after the title suggested to write a brief specification of the algorithm text. algorithm name should be brief but adequately describes what will be done by the algorithm.

Example:

Program Area_cube  "
{title algorithm}"
{calculate the area of ​​the cube to the size of the side that is read from the input device and then print the result to the output device} " {algorithm specification}"

notes:
to separate between words in the title of the algorithm uses the sign "_" is not a necessity. you can write an extensive area of ​​a circle or a circle. but you should not use spaces to separate between words in the algorithm.



DICTIONARY (Declaration)
Dictionary is part of the text as a place to define the algorithm:
  • Name type
  • Constant name
  • Variable name
  • The name of the function
  • Name of procedure
All the new name can be used in the algorithm if it has been defined in the dictionary first. writing a set of names in the dictionary should be grouped by type name.

Blm-defining variable name value when defined. defining a constant as well as providing constant prices, the defining name of the function performed well with the domain / range and specifications. defining the procedure name at a time by defining the parameters (if any) and specification procedures (initial condition "initial state", the end of the "final state" and the processes undertaken).

Algorithm (Description)
The algorithm is a core part of the algorithm that contains the instructions or call the action that has been defined. text component algorithms in procedural programming can be:
  • Basic instructions such as input / output, assignment
  • Sequence (sequence)
  • Analysis case
  • Iteration
every step of the algorithm is read from top to bottom. sequence determines the sequence of steps of writing a description of command execution.

Example:

Algorithm
input (c, d) {accept enter two numbers c and 2}
if c <d then the conditional operation} {
e = a + b {e in the assignment by the value of a and b}
else
e = a-b
output (e) {output such as number e}

Leave reply

Back to Top