Algorithms - EduqasDesigning algorithms with pseudocode

Algorithms are step-by-step plans for solving problems. They are a starting point when writing a program. Algorithms can be designed using pseudo-code and flowcharts.

Part ofComputer ScienceUnderstanding Computer Science

Designing algorithms with pseudocode

An is a logical, step-by-step process for solving a problem. Algorithms are normally written using one of the following methods:

  • a

An algorithm should be seen as a starting point when writing a . The finished program should follow the steps the algorithm describes.

Before an algorithm can be designed, it is important to check that the problem is completely . The decomposed problem should consider:

  • the into the problem
  • the of the problem
  • the order in which need to be carried out
  • any decisions that need to be made in the problem
  • any areas of the problem that are repeated

Only when a problem is properly decomposed and understood can an algorithm design begin.

Pseudocode

Programs are developed using . These languages have specific that must be used so that the program will run properly.

Pseudocode is not an actual programming language. Instead, it is a simple way of describing a set of instructions in a manner that resembles a programming language. It has its own syntax, some of which is very similar to many actual programming languages. Any algorithms designed using pseudocode will not run unless they are converted into an actual programming language.

This simple pseudocode algorithm asks a user to input their favourite subject:

while answer == “computer science” input “What is your favourite subject?” answer if answer == “computer science” output “Good choice!” else output “Really?” end if
repeat

Pseudocode covers many areas of programming and there are different variants.

Advantages and disadvantages of pseudocode

Designing an algorithm in pseudocode has several benefits:

  • because pseudocode is similar to a programming language, it can be quickly and easily converted into an actual programming language
  • it is fairly easy to understand, even for non-programmers
  • it does not matter if there are errors in the syntax as long as it is still obvious what is intended
  • changes to the design can be incorporated quite easily

Pseudocode also has its disadvantages:

  • It can be hard to see how a program flows. For example, where does following one path, as opposed to another, take the program?
  • It can be time-consuming to produce.