Vous êtes sur la page 1sur 3

See

discussions, stats, and author profiles for this publication at: https://www.researchgate.net/publication/262177645

Programming and mathematical thinking

Article in ACM Inroads · March 2014


DOI: 10.1145/2568195.2568207

CITATIONS READS

3 75

2 authors, including:

Peter B. Henderson
Butler University
145 PUBLICATIONS 599 CITATIONS

SEE PROFILE

Some of the authors of this publication are also working on these related projects:

Math in CS Education View project

software engineering education View project

All content following this page was uploaded by Peter B. Henderson on 22 February 2017.

The user has requested enhancement of the downloaded file.


INSI G HTS

MATH COUNTS
for us, as programmers, to cultivate. It can
Peter B. help to clarify our thinking about design
problems; in fact, solutions often become
Henderson obvious. And we inherit a well-understood
vocabulary for specifying and document-
ing our programs and for discussing them
with other programmers.
For example, consider this simple pro-
gramming problem. Suppose that we are
writing software to analyze web pages,
and we want some code that will read

Programming and two web pages and find all of the URLs
that appear in both. Some programmers
might approach the problem like this:

Mathematical Thinking First I’ll read the first web page and
store all the URLs I find in a list.
Then I’ll read the second web page
and, every time I find a URL, search
Editor’s Note: tures in day-to-day programming is lost the list for it. But wait: I don’t want
Peter B. Henderson and for many students. to include the same URL in my result
Allan M. Stavely The courses in my department have more than once. I’ll keep a second
co-authored this column long followed a familiar pattern: introduc- list of the URLs that I’ve already
tory programming in the first semester, found in both web pages, and
OUR GUEST CONTRIBUTOR for this data structures and algorithms in the sec- search that before I search the list of
Math CountS column is Allan Stavely, who ond semester, and a discrete mathematics URLs from the first web page.
recently wrote Programming and Math- course in the second year as a prerequisite
ematical Thinking: A Gentle Introduction to several courses in the third and fourth But a programmer who is accustomed
Featuring Python [2], which will be avail- year. Many of my students never saw the to thinking in terms of discrete-mathemat-
able in early 2014. In this column, Allan point of the discrete math course at the ical structures might immediately think of
gives his motivation for writing this book, time they were taking it; students call a different approach:
shares his insights on the role mathemat- the course “Weird Math.” Courses like The URLs in a web page are a set.
ics can play in the curricula, and provides the third-year analysis-of-algorithms and I’ll read each web page and build
some guidelines for achieving these goals. formal-languages-and-automata courses up the set of URLs in each using set
would use discrete-math structures, of insertion. Then I can get the URLs
I’d like to second a statement that the course, so that when the students hit my common to both web pages by us-
editor of this column made previously, fourth-year compiler-writing course they ing set intersection.
but push it farther. In his September 2013 could cope with the sets and trees and
column Dr. Henderson, speaking of the directed graphs used in compiler writing. Either approach will work, but the
current state of mathematics in under- However, I suspect that many of the stu- second is conceptually simpler and it will
graduate computer science, said: dents left the course thinking that discrete probably be more straightforward to
The mathematical foundation structures are used only in such advanced implement. In fact, once the problem is
concepts are not used or reinforced and exotic computer science topics. described in mathematical terms, most of
effectively in most computer sci- On the contrary, I claim that concepts the design work is already done.
ence courses, the relevant connec- of discrete mathematics are enormously Programmers can exploit the properties
tions between these mathematical useful in even the most basic kinds of of sets and relations and other discrete
concepts and the fundamental programming. Let me quote from a forth- structures in their work even before they
concepts of computer science are coming textbook of mine. The example study those structures formally and learn
not made, and the importance of is adapted from my book Toward Zero- how to construct proofs using them.
mathematics as a tool for reason- Defect Programming [3]. Beginning computer science students can
ing, problem solving and analysis, Many experienced programmers often do their work more skillfully and
and solution verification are lost for approach the design of a program by professionally, as in the example above,
many students. describing its input, output, and internal if they think in terms of the discrete
data objects in the vocabulary of discrete structures when formulating designs. So
To the last point, I would add: the mathematics: sets, sequences, mappings, can programming students who aren’t
importance of discrete-mathematics struc- relations, and so on. This is a useful habit computer science majors.

2014 March  •  Vol. 5  •  No. 1  acm Inroads  35


INSI G H TS
Programming and Mathematical Thinking

As an analogy: most people in our soci- Mastery at the usage level can be in a first university course for students
ety don’t do geometry proofs in their daily taught very early too. How this is done with some experience with programming.
work. They may not remember how from will depend on, among other things, the It could even be used in a pre-university
their high-school geometry course; some programming language used in the first course. For students with no programming
may have never taken a geometry course. course or two. In Python, for example, set experience at all, the book can be used in
But everyone knows what a circle and notation is built into the language and the first course along with other materials
a rectangle are, and can draw examples “set” is a predefined data type, imple- that teach introductory programming, or
without a moment’s thought when draw- mented with hashing so that membership in a second course. The only mathematics
ing (for example) a poster for a bake sale. testing is fast. Then mastery at the usage prerequisites are algebra and logarithms. If
Most know how to construct a precise level simply requires learning the syntax you would like to see the table of contents
circle using a compass and a precise rect- for sets and set operations and completing and preface, please send me email.
angle using a drafting square and a ruler, a programming assignment or two using I have one more suggestion to make to
using the fundamental properties of circles sets. If the language is C or something computer science departments. Mathemat-
and rectangles informally, and perhaps similar, students can be given a set library ics departments have often taught the first
unconsciously, but effectively. to use in a programming assignment, rigorous course in discrete mathematics.
Shouldn’t every programming student but it might be better to ask students to Some computer science departments, to
be just as familiar with sets and relations, implement sets using arrays or linked lists gain more control over the course and to
directed graphs, and the other basic or whatever data structure they already make sure that topics relevant to CS are in-
concepts of discrete mathematics? And know. A toy problem and a toy implemen- cluded, have taught a version of the course
shouldn’t programming students use tation may be good enough at this level. themselves. But, even so, the course
these concepts just as spontaneously in Mastery at the assessment level can has often been taught by someone with
program design? wait until later, typically until the first limited experience and involvement with
Following the proposed Curriculum data-structures-and-algorithms course, programming, either a teaching assistant
2013 [1], we can distinguish three levels when students will learn the efficient data or a theoretically-oriented faculty mem-
of mastery of concepts: structures and algorithms for implement- ber. Consider assigning a real software
■ Familiarity: basic awareness of a con- ing sets and how to compare different person to the course, someone with real
cept; for example, the concept of a set. implementations using mathematical involvement with programming, who can
■ Usage: ability to use the concept in a arguments. But this doesn’t need to be reinforce the relevance of the mathematics
concrete way; for example, ability to the first time a student hears about sets in not only to advanced topics in computer
use sets in a program. programs. science, but to all programming. Ir
■ Assessment: ability to select an ap- Think of how we teach programming in
propriate approach from understood general. We don’t teach everything a stu- References
alternatives; for example, ability to dent needs to know about programming all [1] The Joint Task Force on Computing Curricula, Associa-
tion for Computing Machinery, IEEE-Computer Society.
select the best data structure and algo- in one course, once and only once. We give “Computer Science Curricula 2013, Final Report 0.9 (Pre-
rithms to implement sets in a particular a simple introduction in the first course, release version)” (October 2013): 34. http://ai.stanford.
edu/users/sahami/CS2013/final-draft/CS2013-Final-v0.9-
situation. then build on this introduction step-by-step prerelease.pdf Accessed 2013 November 4.
in all the courses that follow. Everything [2] Stavely, A. Programming and Mathematical Thinking: A
Gentle Introduction to Discrete Mathematics Featuring
There is no reason that discrete that the student learns about programming Python. To be published by The New Mexico Tech Press in
structures at the familiarity level cannot early is reinforced many times throughout early 2014.
[3] Stavely, A. Toward Zero-Defect Programming (Reading,
be taught very early in the curriculum, the rest of the curriculum. MA: Addison Wesley Longman, 1999): 142-143.
perhaps in or in parallel with the first pro- So should we teach everything that
gramming course. Students should learn, the student needs to know about discrete Peter B. Henderson
for example, that a collection of data can mathematics once and only once, in the Emeritus, Department of Computer
Science & Software Engineering
very often be thought of as a set. Then first discrete-math course or in the first Butler University
a student, in thinking of approaches to data-structures-and-algorithms course? Indianapolis, Indiana 46208 USA
phenders@butler.edu
a programming problem, should learn to Certainly not. Students should hear about
notice when a particular collection of data discrete-math concepts starting as early
is conceptually a set. Knowing the most as the first course and the vocabulary of
basic properties of sets, to keep in mind discrete math should be part of everyday
Allan M. Stavely
“I don’t need to keep the data in order” language throughout the curriculum. Emeritus, Computer Science Department
or “I can’t assume that the data is in any The new book mentioned above [2] New Mexico Tech
Socorro, New Mexico 87801 USA
particular order,” and “I can assume that introduces discrete-mathematical struc- al@nmt.edu
there are no duplicates” or “I must make tures at the familiarity and usage levels to
sure that there are never any duplicates,” programming students, applying the ideas DOI: 10.1145/2568195.2568207
while developing the program. expressed here. It was written to be used Copyright held by author.

36  acm Inroads  2014 March  •  Vol. 5  •  No. 1

View publication stats

Vous aimerez peut-être aussi