levo

Algorithms

Designing and analysing an algorithm

  • 1 thing to know
  • Component 02
Start revising · £5/month

Overview

Recall questions on what an algorithm is, analysing a problem before designing, decomposition, pre-conditions and post-conditions, expressing designs, trace tables, off-by-one and boundary testing, iterative versus recursive designs, choosing data structures and generality.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Process

Give three ways an algorithm can be expressed at the design stage.

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    What is an algorithm?

    Model answer

    A finite sequence of unambiguous steps that takes some input, carries out a defined process and produces an output, solving a problem or completing a task. It must be precise enough that it can be followed without judgement, and it must terminate rather than run forever.

  2. 2

    A student says 'my program is my algorithm'. Why is that not quite right?

    Model answer

    An algorithm is the method itself, independent of any language. A program is one implementation of it. The same algorithm can be written in Python, in pseudocode, as a flowchart or in structured English, and it is still the same algorithm, so the method can be analysed and compared before a single line of code is written.

  3. 3

    What are the first things you should establish when analysing a problem before designing an algorithm?

    Model answer

    What the inputs are and where they come from, what output is required and in what form, what processing turns one into the other, what data will be stored and in what structure, and what constraints apply such as how much data there will be, how fast it must run and how much memory is available.

  4. 4

    Explain how decomposition helps in the design of an algorithm.

    Model answer

    Decomposition breaks a large problem into smaller sub-problems, each of which can be solved, tested and understood separately. It makes the design manageable, allows different sub-problems to be worked on independently or reused elsewhere, and means a fault can be located in one small part rather than across the whole solution.

  5. 5

    What is a pre-condition, and why should an algorithm's design state it?

    Model answer

    A pre-condition is something that must be true before the algorithm is run for it to work correctly, for example that the list is already sorted or that the input value is positive. Stating it makes clear whose responsibility the check is, and prevents the algorithm being used in a situation where it will silently give a wrong answer.

  6. 6

    Give three ways an algorithm can be expressed at the design stage.

    Model answer

    Structured English, pseudocode, and a flowchart. All three express the same logic; the choice is about who has to read it. Pseudocode is close enough to code to translate directly, a flowchart makes the flow of control visible, and structured English is easiest for a non-programmer to check.

Other ways to work this

The same content, four other ways.

Everything in your subscription

Runs, plus a mode for every other kind of session.

1Flash
2Imposter
3Fade
4Brain dump

Learn every subtopic in runs of four questions

Facts flash and fade, a wrong word hides in some of them, and a brain dump decides which questions are locked in.

Processors: Structure, Performance and Types
Input, Output and Storage
Systems Software
Applications Generation

Cram the night before, weakest topic first

A quick scan finds your weakest topics. Recall each fact you missed three times in a row.

If it matches, the search .
succeedsfailsrestarts

Blank Blitz consolidates the facts

Rapid timed gap-fills on the terms and numbers you need to recall without thinking.

✓What it iscovered
~Why it happenspartly there
How long it lastsnot there yet

Explain It tests your understanding

Explain a concept in your own words and see which of its points you covered.

A global variable means a variable reachable from anywhere in the program.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The faults are the mistakes students make most often.

721941163128510

Brain Breaks between sessions

Short focus games to reset attention, so the next set lands better than the last.

Every question in Algorithms, on a schedule.

Learn it in runs of four questions, each ending on a brain dump against the clock. Every question you lock in comes back the next day, then at longer gaps, each time just before you would forget it.

Or £46 a year, about £3.83 a month. Cancel anytime.