Introduction

Computers were created to solve problems. But they cando this we need to be able to understand the problem, how to break it down into simple and logical steps. Computational thinking techniques support us with these tasks.

The four main techniques are:

  1. Thinking Abstractly.
  2. Thinking Ahead.
  3. Thinking Procedurally.
  4. Thinking Logically and Concurrently.

text


Thinking Abstractly

text Abstraction relates to focusing on the information which is important to solving the current problem and ignoring the rest. Computer models (e.g. modelling the environment, a flight simulator) are abstractions. The London underground map is a great example. Tube lines are drawn in mostly straight lines with evenly spaced stops. The actual distance between stops is not considered important.

Why do we use abstraction?

If we just focus on the required features to solve a problem, the program will be simpler so therefore more likely to be solvable. Complexity could detract from the main purpose of the program. Abstraction also reduces:

  • processing time so that the program can run on lower spec computers
  • memory usage
  • time taken to implement the solution

Abstraction Techniques:

So when creating an abstraction such as a tube map:

  • Irrelevant details are ignored e.g. scale, distances, platforms, passengers.
  • Symbols or keys are used where the detailed image is not required. For example a dot rather than a picture of an actual tube station.

text


Thinking Ahead

When planning to solve a problem we need to consider a number of questions:

  1. What inputs and outputs will be required?
  2. Are there any preconditions? That is, is there any action that needs to be completed first? For example a program which opens a file to read data might specify the pre-condition that the file must exist in its documentation.
  3. For faster development times consider the benefits and drawbacks of modularity:
    1. Will we want to make any components re-useable? For example if you are writing a program to emails football fans you will need to write functions to use email. Do you think you might want to use your email functions again? Functions to be used repeatedly are often built into external libraries.
    2. Libraries can be shared at run time or embedded into a new program.
    3. Do we want to create classes which can also be re-used in other programs?
    4. However creating classes and sub procedures takes more time to design.
  4. What are the benefits and drawbacks of caching?
    1. Caching is the temporary storage of previously used program instructions or data in cache or RAM that for faster access. Retrieving data from the cache is handled automatically by the operating system. An example would be web caching where recently visited webpage data and images are stored to support faster access and reduce bandwidth issues.
    2. However, if the data is cached and not used again this is a waste of an important resource.
  5. RAM can also be used for faster access if cache memory is not avaiable.

text

Thinking Procedurally

text

The aim of thinking procedurally is to:

  1. Establish the main parts of the solution.
  2. Identify the sub procedures (decomposition).
  3. Determine the sequence for those main steps.

Decomposition

This is the technique of splitting the problem into smaller sub problems. Repeated decomposition (see Top Down Design) should take you to the level where you can "solve" the problem by writing a sub routine (e.g. a function or a procedure) The workload can then be shared amongst many programming teams who can work concurrently thus speeding up development time.

Top Down Design

This is the technique of breaking down a problem into sub tasks.. and then breaking each of those sub tasks into their sub tasks.. and so on. Here is a heirarchy chart for the example of drawing a figure.

text


Thinking Logically and Concurrently

As programmers we want to make sure that our programs are clear and well structured. There are only three basic programming structures:

If..else

text

text

Switch

text

text


Concurrent Programming

For a well structured and clear program we need to:

  • Determine the step where a decision has to be taken.
  • Identify the conditions which affect the outcome of a decision.
  • Decide how decisions can affect the flow of the program e.g. branching.
  • Decide the parts of a program which can be handled at the same time or at least overlap.
  • Identifying the advantages and disadvantages of concurrent programming:
    • Hardware - concurrent processes can run on separate threads each as it's own lifeline. But only one process can run at a time on a single processor.
    • Threads may need to share hardware resources
    • Data may need to be locked while one thread execute, so that it isn't accessed by another thread which might lead to corruption.
    • This might lead to bottlenecks while threads wait to access the resource or data.
    • Threads may be reliant on the result on another threads processing.

text


Tools for Designing Algorithms

Two main methods used to design algorithms are:

  1. Flow Diagrams
  2. Pseudocode.

Flowcharts

A flow chart represents the flow of a program from start to end in a clear, visual diagram. Specific symbols are used for each type of process. Find out more here.

text


A Level Only - Pseudocode


Pseudocode is a way to logically plan write out an algorithm before you write your code. This helps programmers to focus on the logic of the program without getting bogged down in syntax errors.

Pseudocode follows the structure of actual code (e.g. indenting) but is written in plain English with no specific set of rules.

However your exam board requires you to understand their pseudocode which is found in the specification.

Here is one of their examples of pseudocode showing iteration.

text


A Level Units and Videos

2.1.1 Thinking Abstractly

(a) The nature of abstraction.

(b) The need for abstraction.

(c) The differences between an abstraction and reality.

(d) Devise an abstract model for a variety of situations.

2.1.2 Thinking Ahead

(a) Identify the inputs and outputs for a given situation.

(b) Determine the preconditions for devising a solution to a problem.

(c) The nature, benefits and drawbacks of caching.

(d) The need for reusable program components.

2.1.3 Thinking Procedurally

(a) Identify the components of a problem.

(b) Identify the components of a solution to a problem.

(c) Determine the order of the steps needed to solve a problem.

(d) Identify sub procedures necessary to solve a problem.

2.1.4 Thinking Logically

(a) Identify the points in a solution where a decision has to be taken.

(b) Determine the logical conditions that affect the outcome of a decision.

(c) Determine how decisions affect flow through a program

2.1.5 Thinking Concurrently

(a) Determine the parts of a problem that can be tackled at the same time.

(b) Outline the benefits and trade offs that might result from concurrent processing in a particular situation.