Professional Documents
Culture Documents
Hodder Computational Thinking Chapter 5
Hodder Computational Thinking Chapter 5
Computational thinking
Introduction
The expression ‘computational thinking’ is talked about a lot in computing and educational circles these days. It
is not a new concept; the term was first coined in 1996 by Seymour Papert.
Computing people
Seymour Papert
Seymour Papert is a computer scientist who, among other things, helped to develop Logo – a programming
language that aimed to help students think ‘computationally’.
Extra info
Logo is a programming language designed by Seymour Papert (among others), and is intended to help children
learn programming as well as mathematical concepts. It is very easy to learn and its most well-known feature
is turtle graphics, where a screen object called a ‘turtle’ is driven around the screen under programmatic or
direct command. Logo is still useful today in demonstrating computational thinking topics such as abstraction
and decomposition.
®
An implementation of turtle graphics is available for Python and its commands are accessible once the ‘turtle’
library is loaded into the Python programming environment.
Here is a demonstration program that draws a succession of concentric circles.
Computer systems are notoriously difficult to produce. Non-trivial systems soon become complex and, because
of this, various methodologies and strategies have been developed to make development easier and to keep large
projects under control (see Chapter 9).
The discipline of software engineering is concerned with this aspect of systems
development and certain practices have become standard and have stood the test of time.
New ideas continue to evolve to refine the process yet further.
As well as the development of systems, the greater use of computers has helped to change
the way we think about things and understand the world and the universe. One good example
is the realisation that we ourselves are the product of digital information in the form of our
own DNA.
The realisation that the complexities of life and the world around us are explainable in
terms of information systems and often very simple processes, has allowed us to look at the
world and ourselves in a new and powerful way.
Understanding how things work in terms of natural information systems also allows us to
produce new inventions based on the changed perspectives that computers bring us; for
example neural networks borrow understanding from animal nervous systems in order to
process large numbers of inputs and predict outcomes that are otherwise uncertain. Some
success continues to result from research into artificial intelligence, again, using systems that
mimic human behaviour.
In recent years, the nature of computational thinking has been developed and given much
publicity and impetus by Jeannette Wing in the US.
Key term
Computational thinking A problem-solving approach that borrows techniques from
computer science, notably abstraction, problem decomposition and the development of
algorithms. Computational thinking is applied to a wide variety of problem domains and
not just to the development of computer systems.
Computing people
Jeannette Wing
At the time of writing, Jeannette Wing is Corporate Vice President of Microsoft Research. In this role she
oversees Microsoft’s various research laboratories around the world.
Jeannette Wing has had a distinguished career. Prior to joining Microsoft, she worked at the University of
Southern California and then Carnegie Mellon University in Pittsburgh, where she was President’s Professor of
Computer Science.
While at Carnegie Mellon, she devoted much energy to the promotion of computational thinking and how it is a
powerful approach to solving a wide variety of problems, not necessarily involving computers. She sees it as a
vital skill that should be taught to all children, as important as the 3Rs.
Carnegie Mellon still has a ‘Center for Computational Thinking’, where computational thinking applications are
explored and new ways to apply it are devised.
A drawback of the top-down approach is that it assumes that the whole solution to the problem is knowable in
advance. Increasingly, this is not the case, and plans and ideas change as a project develops. Nonetheless, as a
starting point, it is useful if a problem can be split up even to some extent.
Also, this hierarchical approach is less useful with many more modern applications. With
the widespread adoption of event-driven programming, such a neat top-down structure is not
always appropriate. However, it is a computational tool that still has its uses.
Decomposition does not have to be hierarchical. It can take into account parallel processes,
where alternative paths are possible. It is still a help in breaking down the problem.
Decomposition can be applied at various levels in computing scenarios. As we have seen,
we can break down a problem into different functional components that lead to modules or
program procedures. We can also break a problem down into processes, data stores and data
flows. This approach, again developed in the 1970s, leads to a data-flow diagram. The
advantage of this approach is that the major components and activities in a system are laid out
before any effort is expended on the finer details of algorithm development.
Structured programming
Early programs were commonly developed on an ad hoc basis, with no particular rules as to how to lay them
out. In particular, programmers often used the now infamousGOTO statement that transferred control
unconditionally to some other point in a program.
IF condition THEN goto label
or worse
IF condition THEN goto 230
This made programs very hard to read and maintain and was vigorously opposed by the computer scientist
Edsger Dijkstra, notably in a letter entitled Go To Statement Considered Harmful, where Dijkstra argued for
banning the construct from all languages, and over time it did indeed drop from favour, being replaced
by structured programming. In structured programming, functions (or procedures) were packaged off and
designed to perform just one or a limited set of jobs. This improved readability and you should still make sure
that your programs are packaged up into fairly simple modules.
Structured programming gained favour also because it was shown by Böhm and Jacopini
in 1966 that any computable function can be carried out by using no more than three different
types of programming construct, thereby eliminating the need for GOTO.
These constructs are:
1. sequence: executing one statement or subprogram after another
2. selection: branching to a different place in a program according to the value of a Boolean
expression
3. iteration: repeating a section of code until a Boolean expression is true.
So, structured programming is another common method of decomposition routinely used by computer
professionals and we can learn from it when tackling many everyday problems – solve one problem at a time!
Key point
Structured programming remains one of the key factors that affects the way in which your practical
programming course work is marked and judged.
Objects
Object-oriented programming is a common way of breaking down problems and functionality at the same
time. An object, which is based on a class, is a container of attributes (data) and methods (code). This is popular
because each object can be isolated from others, which minimises errors due to interference, and it also
facilitates the reuse of objects for similar problems. For a full coverage of objects, see pages 91–96.
Key term
Object-oriented programming A program made up of objects (custom-made data structures
to represent often-used real-world entities) that interact. Object-oriented languages include
Java and C . Object-oriented programming is covered in more detail at the end of Chapter
6.
Example
A friend is travelling to visit you at your home. You need to explain how to get there. Consider the following
approaches:
1. Get the train to Central Station, then get a taxi to 24 Acacia Avenue.
2. Get the train to Central Station, then get the number 23 bus. Get off the bus after six stops,
walk down Back Street, take the second right into Acacia Avenue. Number 24 is 100 metres
along on the right.
Clearly, the level of decomposition can be tailored to the need of the moment.
Questions
1 0
A decimal number such as 21 can be decomposed into its separate digits; that is, 2 × 10 1 ×10 .
1. Decompose the binary number 1000001.
2. Decompose the decimal equivalent of binary 1000001.
3. Decompose the hexadecimal decimal equivalent of binary 1000001.
Key points
– Algorithms are an integral part of the decomposition process.
– Small problems extracted from big problems should be solvable by an algorithm.
– Recursive algorithms are particularly useful in solving simple repetitive problems that may
have any number of iterations.
This is a recursive algorithm called ‘search’. Recursive means that when written as a function, it calls itself from
within itself. Notice the lines that start with ‘return search’. The beauty of writing this recursively is that very
little code is needed to produce an iterative search that will occur as often as needed.
Algorithms cannot work on their own. They are designed to ‘do something’ ‘to’ or ‘with’ something else. The
something else is data. If the data has been structured, as in an ordered list, this makes devising an efficient
algorithm that much easier. This is another lesson to learn when applying computational thinking to real-world
problems.
Designers of algorithms need to bear certain things in mind when producing an algorithmic
solution.
Algorithms must exactly describe what they are supposed to do. Any ambiguity will make
them unreliable when implemented. Computers don’t understand vagueness (unless
programmed to do so in an unambiguous way!).
Algorithms must end. No end means no result. This is something to watch for in recursive
algorithms. It is easy to miss out an end condition.
Algorithms must be correct. There is no point in running an algorithm if the end result is
incorrect.
Algorithms must work with any instance of the same problem. The whole point of
presenting algorithms to a computer is that they can be applied to different sets of similar
data.
Question
What is the end condition in the binary search implementation given on this page?
Once an algorithm has been designed, next comes the easy bit – coding it into a
programming language. A programmer who knows the syntax of a given language should be
able to translate a well-designed algorithm into code.
Key points
– Computer scientists have long learned the power of decomposition to solve problems.
– Many ways of decomposition have been developed.
– We can use this key concept to solve many everyday problems.
Practice questions
1. Define the term ‘recursion’.
2. GNU is an operating system. Explain why the name GNU is recursive.
3. A library accepts new members and stores data about them. It issues them with a card. It also
updates membership details when necessary. When the member leaves, the record for that
member is deleted.
Express this library system as a data-flow diagram.