Titles in Development


Thinking About Programs

Author(s): Gavin Lowe
(Collection III)

This book describes how to think about computer programs, and how to use mathematics as part of that thinking. Many books and online tutorials teach the basics of coding: the syntax of the language, and how to translate an algorithm into code. But how do you come up with that algorithm? And how can you be confident that the algorithm is correct?

The first part of the book considers small programs that use a loop, and how to demonstrate their correctness using loop invariants. It also covers some algorithms and algorithmic techniques that every programmer should know. The second half of the book considers slightly larger programs. It teaches the basics of modularization, splitting up a program into manageable chunks. It teaches about abstract datatypes, values within a program that can be treated as mathematical values: how to specify their behaviors formally; and how to treat them as abstract mathematical objects when programming. It also teaches how to use data structures to represent abstract datatypes, and what it means for such a representation to be correct. And it presents some abstract datatypes and data structures that every programmer should know.

The book is aimed at those who want to obtain a better understanding of programs they work on and so become better programmers. The target audience ranges from undergraduate students who are just starting out, to professional programmers. The book aims to be pragmatic: the philosophy is to include enough formality to be convincing and to guide the programmer toward correct code, without getting bogged down in the mathematics.


Chapters
I Programming with Loops 1
First Steps
Summing a Sequence
Exponentiation: Slow and Fast
Rules for Annotations
Searching in an Array
Example: Integer Square Roots
Calculating the Value of a Polynomial
Recursion
Binary Search
Selection Sort
Quicksort
Dynamic Programming
Example: Maximum Segment Sums
II Abstract Datatypes and Data Structures
Modularisation and Abstract Datatypes
A Club Account Application
Programming with Abstract Datatypes
Countdown: The Numbers Game
Implementing Abstract Datatypes
Linked Lists
Bit Maps
Hash Tables
Binary Search Trees
Finding Shortest Paths
Binary Heaps and Priority Queues
Countdown: The Letters Game
Solving Sudoku Puzzles
A An Introduction to Predicate Logic
B Analysing the Efficiency of Programs


< Back to Titles in Development List