introduction_to_computational_thinking_printable
introduction_to_computational_thinking_printable
Introduction
One can major [i.e. graduate] in computer science and do anything. One can
major in English or mathematics and go on to a multitude of different careers.
Ditto computer science. One can major in computer science and go on to a
career in medicine, law, business, politics, any type of science or engineering,
and even the arts.
Jeannette M. Wing, Professor of Computer Science at Carnegie Mellon University (United
States) and Head of Microsoft Research International
Sounds great that ‘One can major [i.e. graduate] in computer science and do anything’,
doesn’t it? Then again, isn’t this miles away from the view of computing as a training
ground for programmers and system builders? The good news is that one doesn’t
necessarily need to exclude the other! The grand vision behind this quote is that learning
to program, build large systems, and so on, allows you to develop something which is
much more valuable than any of these on their own, namely the ability to think like a
computer scientist. Over the past decade or so, Jeannette Wing has been popularising
this view under the banner of computational thinking.
Discussion
First, we need to consider whether the text describes a step-by-step list of instructions.
This is not always obvious. At some points it does and at some points it doesn’t.
At many points the text does provide instructions to be carried out sequentially,
such as:
● ‘place the numbers so that each figure may stand directly underneath (…) the
figures of the same value’
● ‘begin the addition at the first place’.
Although other parts of the instructions are not explicitly presented as a list of
instructions, it is easy to see how the textual passage could be mapped onto such a
list. In that list, certain instructions would be repeated for each of the columns involved
(‘then proceed in the same manner … from place to place to the last’).
So, let’s assume that the text does have the first property. Does it also have the other
two properties?
According to the second property, the process should be finite. This is indeed the case.
The numbers being added will each have a finite number of digits, so only a finite
number of columns will be involved, and the process only requires a small number of
steps at each column.
Finally, the process does apply to any instance of the problem, where the ‘instances of
the problem’ are all combinations of three integers, each represented by a finite
sequence of digits in the range 0–9. The text leaves it implicit what instances the
algorithm is intended to apply to.
The precise specification of the ‘instance of the problem’ can be thought of as part of
the task of formulating a problem as a computational problem. By a computational
problem, we mean "a problem that is stated sufficiently precisely such that one can
attempt to write an algorithm to solve it."
Figure 3 (a) Human computers working on test flight calculations at the predecessor of
NASA in 1949 (b) two NASA employees in 1990 programming a computer so it can
automatically calibrate aircraft equipment
Having met the ideas of algorithms and computational problems, let us state what
computational thinking is not: computational thinking is not about us humans following an
algorithm when carrying out the task of adding numbers on paper or in our head. It is not
about thinking like a computer - rather, computational thinking is first and foremost
thinking about computation. In particular, computational thinking consists of the skills to:
A computational thinker can take a problem and state it sufficiently precisely for it to be
potentially solvable by an algorithm. Once the problem has been stated in the right way, a
computational thinker tries to construct an algorithm that solves it. A computational thinker
won’t, however, be satisfied with just any solution: the solution has to be a ‘good’ one. We
will discuss two specific properties of a good solution later on in this course: efficiency and
correctness. Finally, computational thinking goes beyond finding solutions: if no good
solution exists, one should be able to explain why this is so. This topic, however, takes us
beyond the scope of this course into computability and computational complexity theory.
Most of the activities in this course involve watching extracts from Wing’s presentation
‘Computational Thinking and Thinking About Computing’. Remember to read through
the activity before watching the video.
1.1 Automation
After you’ve watched the following extract of Wing’s talk, complete this activity.
The aim of this activity is to get you to think about what Wing is saying in the following,
rather long but important, sentence: ‘… this feedback loop that one has when you’re
abstracting from some physical-world phenomenon, creating a mathematical model of
this physical-world phenomenon, and then analysing the abstraction, doing sorts of
manipulations of those abstractions, and in fact automating the abstraction, that then
tells us more about the physical-world phenomenon that we’re actually modelling.’
Place the following labels in the correct positions of the diagram below. (Note: the
diagram will not work with Internet Explorer 8, if this is your usual browser you will need
to use an alternate browser to view the diagram.)
Discussion
It is important to have a good grasp of this diagram. It provides a high-level overview of
the key ingredients of computational thinking and how they are related to each other. In
the remainder of this course, we will flesh out some of the details that lie behind this
diagram.
Activity 3 Abstraction
8 minutes
Wing talks about abstractions as a means of ignoring detail that is not of interest.
Consider the following description of an algorithm for searching a paper and ink
dictionary.
Given:
i. a dictionary
ii. a headword W which appears in the dictionary
Begin the search with an entry that appears (roughly) in the middle of the
dictionary. Then there are three possibilities:
1. The current entry’s headword is W. In this case, the definition of W is the
definition of the current entry.
2. W appears alphabetically before the current entry’s headword. In this
case, the entry with headword W must appear in the first half of the
dictionary. Look for the word W, following the same approach, in the first
half of the dictionary.
3. W appears alphabetically after the current entry’s headword. In this case,
the entry with headword W must appear in the second half of the
dictionary. Look for the word W, following the same approach, in the
second half of the dictionary.
This is an informal description of an algorithm, but the steps are sufficiently precise
that a human should have no problem following them. This algorithm depends crucially
on the fact that the words in a dictionary are alphabetically ordered. It also, however,
ignores some of the details of paper and ink dictionaries. Can you list of few of these?
Figure 4 A dictionary
Discussion
Details of a paper and ink dictionary that come to mind include: the size and thickness
of its pages, the colour of its cover and the size of the printed font. None of these
played a role in the algorithm that is described above. Perhaps the most salient
abstraction relates to the fact that paper and ink dictionaries are made of pages. They
are not simply a list of words and definitions. Rather, the words are distributed across
the pages of the dictionary. The algorithm doesn’t take into account the distribution of
the words in a dictionary across pages: for example it would work equally well with a
dictionary printed on a single, enormously long paper scroll.
Wing’s discussion of abstraction draws on a wide variety of concepts. You have come
across phrases such as ‘ignoring’ and ‘hiding information’, ‘levels’ and ‘layers’, ‘models’
and ‘implementation’. It has been left somewhat in the air how these all hang together. So
next, we will make the relations between them explicit. To do so, we will distinguish
between two kinds of abstraction:
● abstraction as modelling
● abstraction as encapsulation.
Although Wing deals in great detail with the idea of abstraction as modelling, she only
hints at the concept of abstraction as encapsulation. Both are, however, at play in
computing. Distinguishing between them will give you a better understanding of the
remainder of Wing’s story.
2.1 Models
Activity 4 Representations
Representations, including paintings and drawings, are models. This is brilliantly
illustrated by René Magritte’s famous painting of a pipe with the words ‘Ceci n’est pas
une pipe’ (‘This is not a pipe’) underneath (Figure 7). Explain how this painting brings
home the point that modelling involves two levels: the abstraction and the reality which
the abstraction models.
The part of reality for which one creates a model or representation doesn’t need to be a
static object such as a pipe or dictionary. It can also be a process or system which
changes over time. In that case, the model will not only have to capture any enduring
properties of interest, but also any changes in time that are of interest. For example, in
astronomy there is a rich tradition of building such models of the solar system (see
Figure 8). The purpose of such a model, known as an orrery, is to represent the position of
the planets relative to each other over time.
The invention of the orrery is usually attributed to George Graham (1673–1751). Graham
worked on this with the support of the 4th Earl of Orrery, which explains the name. The
tiny crank on the side of the central cylinder in Figure 8 allows the model to be animated.
Turning the crank causes the (representations of the) planets to follow a path around the
(representation of the) Sun at the centre of the model. Usually such an animated model is
referred to as a simulation.
2.2 Encapsulation
The model of the solar system in Figure 10 also illustrates the second type of abstraction:
abstraction as encapsulation. The brass cylinder in the middle of the device encloses a
clockwork of cogwheels similar to the one in Figure 10.
Figure 13 Execution of the small program above in the Python Interactive Shell
How does time.ctime() work? We don’t know and we don’t need to know! Someone
has written the time module and documented its interface, which contains the function
ctime(). We can just use the function without any knowledge whatsoever of its
implementation.
However, under the bonnet the time module is itself a program, written in C, another
high-level programming language! The programmers of the module, when they wrote it,
only needed to know C. They were able to ignore the details of the low-level machine
language that the C program would get translated into.
So now we have three layers of programming abstraction (Figure 14).
Figure 15 The result of the function printUsersTimesTable() when user enters the
number 6
def printUsersTimesTable():
aNumber = input('Please enter your number: ')
timesTable(int(aNumber))
So we can build a hierarchy with any number of layers of abstraction, with the detail of
each layer hidden from those above and each layer – apart from the bottom one –
interacting with the layer below via its interface.
● In the case of modelling, this is done by discarding information: we abstract away all
that is irrelevant, to leave a model that contains only what is actually of interest.
● In the case of encapsulation it is done by hiding information: we encapsulate the
details of an implementation/automation (of a model) behind an interface.
These strategies are utterly essential to all computer modelling. Without modelling we
would be swamped by the complexity of the real world and it would be impossible to
define the problem precisely enough to allow it to be solved using an algorithm. Without
encapsulation we would be swamped by the detail of the ‘computer world’ and would find
it impossible to deal with the complexity required to implement algorithms as computer
programs.
● a physical-world phenomenon
● a mathematical model
● an automaton.
● real-world problem
● computational problem
● algorithm and data structures?
Let us start with Wing’s use of the term ‘mathematical model’. As we will now explain,
Wing’s notion of a mathematical model is linked to that of a computational problem.
According to Wing, a mathematical model is an abstraction of the physical-world
phenomenon of interest. It ignores irrelevant detail. It also is the point of departure for
automation. The fact that it is a mathematical model means that it is sufficiently precise to
be used as a starting point for creating an automaton. Now, you may recall that we defined
a computational problem as a problem that is expressed sufficiently precisely that it is
possible to attempt to build an algorithm to solve it. In other words, Wing’s mathematical
model is nothing other than a computational problem.
Wing’s physical-world phenomenon is abstracted by the mathematical model, just like a
computational problem provides an abstraction of a real-world problem.
Algorithms and data structures form the link between a computational problem and its
automation. Finding algorithms and data structures is part of automating. When these are
then implemented as a program and executed, they provide a machine that solves the
problem. In Wing’s words, the resulting machine – or automaton – automates the
abstraction.
The complexity of the machine, as we have just discussed, is managed by having a series
of encapsulated layers.
To sum all this up, we can refine the diagram of Figure 19 as shown in Figure 20.
Parts 1-8
Watch the video and complete the activity by ticking the appropriate boxes.
Part 1
1. Which of the following use formal notation?
o Computational thinking
o Mathematical thinking
o Engineering thinking
Discussion
In all three disciplines, the use of formal/mathematical notation is common:
Part 2
2.Which of the following involve at least two layers?
o Computational thinking
o Mathematical thinking
o Engineering thinking
Discussion
Mathematics typically works only with a single layer: there is no distinction between the
‘properties of interest’ and the ‘ignored detail’. The abstraction is studied in its own
right, without reference to some other layer which it represents. Of course, this is an
idealisation. Many areas of mathematics did start as a representation of some aspect
of the real world. For example, geometry began with Euclidean geometry, which was
intended as a model of physical space.
Both engineering and computing rely on at least two layers. At the basis, there is a
layer grounded in the real world. This is the layer in which the problem of interest lies
(for example a bridge or car in engineering). In addition to this layer, there is at least
one further layer which ignores certain of its details. For instance, an engineer may use
mechanics to calculate the forces operating on a bridge when a car crosses it. In doing
so, the engineer will abstract away (or ignore), the colour in which the bridge is
painted, the brand of the car, and many other things that are not relevant for calculating
the forces in question. We’ve seen that a computer scientist who simulates a dictionary
may, similarly, ignore certain properties of a physical dictionary.
Part 3
3. For which of the following are beauty and elegance measures of goodness?
o Computational thinking
o Mathematical thinking
o Engineering thinking
Discussion
In all three disciplines, beauty and elegance are criteria that are used to compare
competing abstractions. These are, however, more central in mathematics, where the
abstraction is often judged in its own right, without reference to an underlying reality
that it represents.
Part 4
4. For which of the following is correctness a measure of goodness?
o Computational thinking
o Mathematical thinking
o Engineering thinking
Discussion
In connection with this criterion, Wing asks in particular: ‘Does it do the right thing?’
and ‘Does it do anything?’ These questions are clearly relevant for both computational
and engineering abstractions. It is perhaps less clear what they mean in the context of
mathematics. Arguably, since mathematics is about the abstraction itself, one can’t
really distinguish correct from incorrect abstractions because there is nothing to
compare them with. However, even when dealing with pure abstractions, we may want
to make sure that they are consistent. A mathematical theory that states that a
mathematical object both does and does not have some property would be in violation
of this criterion (e.g. a theory which says that two lines cross and do not cross each
other).
Part 5
5. For which of the following is efficiency a measure of goodness?
o Computational thinking
o Mathematical thinking
o Engineering thinking
Discussion
In connection with computing, Wing mentions three dimensions of efficiency: time
(how fast?), space (how much space?) and energy (how much power?). Each of the
three efficiency criteria can also be applied in engineering contexts (e.g. how fast can
the engine run, how much space does it occupy, and how much energy does it
consume?). None of these considerations has a clear equivalent in mathematics.
Part 6
6. For which of the following are usability, modifiability, maintainability and cost
measures of goodness?
o Computational thinking
o Mathematical thinking
o Engineering thinking
Discussion
All of these practical considerations are important in both engineering and computing
contexts. They are not directly applicable to mathematics.
Part 7
7. Which of the following are constrained by physics?
o Computational thinking
o Mathematical thinking
o Engineering thinking
Discussion
Both engineering and computing are constrained by physical reality. For example, the
classical model of computing uses the bit (0 or 1) as the basic unit of information. It is
constrained by whichever physical means is used to represent a bit (whether it be an
electrical current or, for instance, the position of a mechanical lever). The physical
hardware constrains, among other things, how quickly the state of a bit can be
changed (from 0 to 1 or vice versa).
Part 8
8. Which of the following can go beyond physics?
o Computational thinking
o Mathematical thinking
o Engineering thinking
Discussion
Mathematics, as the study of pure abstractions, is independent of physical reality.
Computing, though always constrained by the physical layer at which the hardware
operates, allows us to build on top of the hardware layer software layers that model
non-existent realities. By automating these virtual realities, it allows us to see and even
experience realities that go beyond what is physically possible.
write down a ‘2’, this is merely a representation, not the actual number. Other people
can write down a ‘2’ as well, and thereby talk about the same number that you’re
talking about when using a ‘2’.
Perhaps this has set you wondering what numbers are, if they aren’t physical objects.
Unfortunately, philosophers have been at loggerheads about this question since the
ancient Greeks started discussing it. Many mathematicians subscribe to a view
championed by the philosopher Plato (429–347 BCE), who proposed that numbers
exist, but not in space and time; rather they inhabit what is known as ‘platonic heaven’.
Wing gives the example of basketball coaches who use machine learning to find out
which skills distinguish good players. Once they know this, they can teach those skills
to their own players. Machine learning makes this possible by automatically finding
patterns in the behaviour of professional players from a large collection of video
recordings.
Describe this use of machine learning in terms of abstraction as modelling.
Discussion
One can view this use of machine learning as an attempt to automatically build a
model of a good basketball player. Such a model is an abstraction that needs to
capture the skills that distinguish a good player and ignores anything else. At a
different level, machine learning is itself based on a model of learning by humans or
animals. Being an abstraction, it ignores many of the details of human and animal
learning, while preserving some key properties (in particular, the idea that one can
learn from examples).
Conclusion
The underlying theme of this course has been ‘computational thinking’. We’ve defined this
as consisting of the skills to:
We introduced the idea of an algorithm with two examples: an algorithm for addition and
one for dictionary search. You learned about the concept of abstraction and its two
varieties: abstraction as modelling and abstraction as encapsulation. We contrasted and
compared computational thinking with both mathematical and engineering thinking. You
have also been shown the ‘bigger picture’: the way that computational thinking is shaping
research in many disciplines, ranging from biology and physics to economics and sport
science.
Glossary
abstraction
provides a handle on complexity by either ignoring detail by means of a model, or
hiding detail through the use of encapsulation.
algorithm
A precisely stated, step-by-step list of instructions.
data structure
A way of organising data for use by an algorithm.
encapsulation
Hiding details of an implementation from users. This is achieved through an interface
that sits between the user (or client) and the implementation.
interface
An interface sits between a user (or client) and an implementation. It hides the details of
the implementation from the users or clients of the implementation. (See encapsula-
tion.)
model
A representation or abstraction of a part of reality which ignores certain details.
simulation
A working model of a process or a system which changes over time.
References
Gough, J. (1767) Practical Arithmetick in Four books, Dublin.
Miller, B. N. and Ranum, D. L. (2011) Problem Solving with Algorithms and Data
Structures using Python, 2nd edn, Sherwood, Oregon, Frankin, Beedle & Associates.
Wing, J. M. (2006) ‘Computational Thinking’, Communications of the ACM, vol. 49, no. 3,
pp. 33–5; also available online at http://www.cs.cmu.edu/~wing/publications/Wing06.pdf
(Accessed 20 December 2012).
Wing, J. M. (2009) ‘Computational Thinking and Thinking About Computing’, Evening
Lecture Series, 2 September 2009, Florida Institute for Human and Machine Cognition,
Florida, US [Online]. Available at http://www.youtube.com/watch?v=C2Pq4N-iE4I (Ac-
cessed 20 December 2012).
Acknowledgements
This course was written by Paul Piwek (with input from Alistair Willis for Activities 1 and 3).
Except for third party materials and otherwise stated (see terms and conditions), this
content is made available under a
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 Licence.
The material acknowledged below is Proprietary, used under licence and not subject to
Creative Commons licence. See terms and conditions. Grateful acknowledgement is
made to the following sources for permission to reproduce material in this course:
Course image: Creativity103 in Flickr made available under
Creative Commons Attribution 2.0 Licence.
Photograph of Jeannette Wing in Sections 2 and 3 from:
www.cmu.edu/news/archive/2010/May/may12_wingtoleadcsd.shtml
Figure 1: Theo van Doesburg:
http://commons.wikimedia.org/wiki/File:Theo_van_doesburg_de_koe.jpg
Figure 3a: NASA
Figure 3b: NASA
Figure 7: © ADAGP, Paris and DACS, London 2013
Figure 8: Professor Mark E. Bailey / Armagh Observatory
Figure 10: Courtesy of Dr David Goodchild
Figure 17: Courtesy of Tim Robinson
Videos of Jeannette Wing’s lecture in Section 3: © Florida Institute for Human & Machine
Cognition (IHMC)
Every effort has been made to contact copyright owners. If any have been inadvertently
overlooked, the publishers will be pleased to make the necessary arrangements at the
first opportunity.
Don't miss out:
If reading this text has inspired you to learn more, you may be interested in joining the
millions of people who discover our free learning resources and qualifications by visiting
The Open University - www.open.edu/openlearn/free-courses