(1.1) What is computer science?
Computer science is no more about computers than astronomy is about telescopes, biology is about microscopes, or chemistry is about beakers and test tubes. Science is not about tools. It is about how we use them, and what we find out when we do. - M. R. Fellows and I. Parberry.
Programming is an important part of the field but it's basically just a tool that we use to study new ideas and test new solutions to problems.
It is not only the construction of a high-quality program that's important but also the methods it uses, the services it provides, and the results it produces.
It's possible to become so enmeshed in writing code and getting it to run that we forget that a program is only a means to an end, not an end in itself.
Learning to use a word processor, spreadsheet, database system, web browser, etc., is no more a part of computer science than driver's education is a branch of automotive engineering.
People in all walks of life use software packages. Computer scientists specify, design, build, and test software packages as well as the hardware on which they run.
(1.2) The Definition of Computer Science
According to N. E. Gibbs and A. B. Tucker, computer science is the study of algorithms, including:
A dictionary definition of the word algorithm:
n. A procedure for solving a mathematical problem in a finite number of steps that frequently involves repetition of an operation; broadly: a step-by-step method for accomplishing some task.
An algorithm is a list that looks something like this:
| Step 1 | Do something |
| Step 2 | Do something |
| Step 3 | Do something |
| . | |
|---|---|
| . | |
| . | |
| Step N | Stop, you are finished |
There are three different types of operations in an algorithm:
Figure 1.2 in the text shows a formal algorithm for adding two m-digit numbers.
Exercise 7 of Chapter 1 on page 34 of the text shows Euclid's algorithm for finding the greatest common divisor (GCD) of two positive integers I and J.
| EUCLID'S ALGORITHM | ||
|---|---|---|
| Step | Operation | |
| 1 | Get two positive integers as input. Call the larger value I and the smaller value J. | |
| 2 | Divide I by J (using the long division algorithm you learned in grade school) to get an integer quotient Q and an integer remainder R. | |
| 3 | If R is not 0, then reset the value of I to the value of J, reset the value of J to the value of R, and go back to Step 2. | |
| 4 | Otherwise the value of R = 0, so print out the value of J as the answer (the GCD of the original values of I and J.) | |
| 5 | Stop. | |
If we can formally specify an algorithm to solve a problem, then we can automate its solution. That is, we can:
Much of the R&D work in computer science involves discovering correct and efficient algorithms for a wide variety of interesting problems.
Does every problem have an algorithmic solution?
Chapter 11 in the text shows some problems that have no algorithmic solutions. These problems are unsolvable. There's a limit on the ultimate capability of computers.
There are also problems with algorithmic solutions but the algorithms would take so long to execute as to render them useless. For example, one could write an algorithm to always win at the game of chess but it would take more than 1028 years to execute.
There are also problems that humans (even babies) can rapidly solve but do not as yet have efficient algorithmic solutions.
(1.3) Algorithms
The formal definition of an algorithm:
... a well-ordered collection ...
An algorithm is a collection of operations, and there must be a clear and unambiguous ordering to these operations: we must know which operation to do first and after each operation we must know which operation to do next.
As an example the text shows an "algorithm" taken from the back of a shampoo bottle:
| Step 1: | Wet hair |
| Step 2: | Lather |
| Step 3: | Rinse |
| Step 4: | Repeat |
Is this a well-ordered set of operations? At step 4 what operations should be repeated?
A well-ordered set of operations can't have ambiguous statements like:
... of unambiguous and effectively computable operations ...
The computing agent must be able to understand each and every step of the algorithm. As an example the text shows a possible "algorithm" for making a cherry pie:
| Step 1: | Make the crust |
| Step 2: | Make the cherry filling |
| Step 3: | Pour the filling into the crust |
| Step 4: | Bake at 350oF for 45 minutes |
Steps 3 and 4 are pretty clear but most of us might need detailed instructions for steps 1 and 2:
| Step 1: | Make the crust | |
|---|---|---|
| 1.1: | Take one and a third cups of flour | |
| 1.2: | Sift the flour | |
| 1.3: | Mix the sifted flour with one-half cup butter and one-fourth cup water | |
| 1.4: | Roll into two 9-inch pie crusts | |
| Step 2: | Make the cherry filling | |
| 2.1: | Open a 16-ounce can of cherry pie filling and pour into bowl | |
| 2.2: | Add a dash of cinnamon and nutmeg, and stir | |
The "computing agent" might not understand how to sift the flour in step 1.2 and would need even more detail:
| Step | 1.2: | Sift the flour |
|---|---|---|
| 1.2.1: | Get out the sifter, which is the device shown on page A-9 of your cookbook, and place it directly on top of a two-quart bowl | |
| 1.2.2: | Pour the flour into the top of the sifter and turn the crank counterclockwise | |
| 1.2.3: | Let all the flour fall through the sifter into the bowl |
An unambiguous operation is so simple that the computing agent can understand and perform it: we call it a primitive operation or simply a primitive.
Each operation must also be effectively computable. Flapping one's arms until you start to fly or generating a list of all prime numbers are not effectively computable.
... that produces a result ...
We say result instead of answer because sometimes there is no correct answer. The result of an algorithm could be an error message instead of a correct answer.
... and halts in a finite amount of time.
The shampooing "algorithm" has an infinite loop.
(1.4) A Brief History of Computing
(1.4.1) The Early Period: Up to 1940. The first computers used ideas that were developed over hundreds of years by many people:
(1.5) Organization of the Text
The rest of the course and the text is organized into a six-layer hierarchy as depicted in Fig. 1.9 of the text.