Writing & Amending Algorithms

  • To create algorithms for a given problem several stages must be followed:
  1. The problem must be sufficiently analysed and understood. The requirements and purpose of the algorithm must be clearly stated
  2. The problem must be sufficiently decomposed into sub-problems. A complex problem may require many sub-problems with each sub-problem requiring their sub-problems and algorithms. When determining an algorithm for a sub-problem developers need to consider inputs, outputs, processes and long term data storage (if necessary)
  3. Consideration must be given to how data is going to be gathered, stored and processed as well as how output is going to be displayed to the user
    • For example, will data be entered via input boxes or file upload/opening? Is data to be stored in a file? What overall processes will be performed on the data? Will the data be displayed on a form, a web page or output into a file?
  4. The structure of the problem and subproblems should be illustrated by creating a structure diagram which details the breakdown and hierarchy of sub-problems
  5. Once each sub-problem is specified, an algorithm can be created using flowcharts or pseudocode. The algorithm should be clear, easy to read and as simple as possible
    • Meaningful variable names help readers understand what data is being stored and their purpose
    • Mathematical symbols such as “=” or “<=” are quicker and simpler to read than “equal to “ or “less than or equal to”. “Percentage < 0 OR Percentage > 100” is clearer than “Percentage under zero or Percentage over one-hundred”. Be concise
  6. Sets of predetermined test data should be dry run on the algorithm, including normal, abnormal, extreme and boundary data. The results should be displayed in a trace table, with clear outputs to allow errors to be detected
  7. Encountered errors should be fixed and the algorithm retested to make sure it functions as intended

Loading

error: Content is protected !!