Notes 7


Algorithms are abstract, a sequence of steps used to to describe how to perform a task. An algorithm can have multiple representations. A program is one representation of an algorithm. An English description is another. A diagram is still another.And in some cases, an equation will work.

The formal definition from the book is
An algorithm is an ordered set of unambigous ,executable steps defining a terminating process.

Algorithm representation is tricky. Using natural language leads to ambiguities. For example, time flies like an arrow has several meanings. It is important that all the partners agree on the terms used to build the representation. These are called primitives.

Programming languages aire built to be unambigous. We all agree what the primitives are and how they are combined. The compiler is the enforcer.

The primitives in a language have both syntax - what it looks like and semantics - what it means. The syntax of assignment in C is
    a = b;
The semantics are that the value stored in b is copied to a.

In some object oriented languages, this might be doen with the syntax
but the semantics are the same.


When developing an algorithm, it is easier to use an informal language to write it. It would be later translated into a formal programming language. We will see a number of examples as we discuss various algorithms.

Problem Solving

The book gives a number of clever examples of how to approach problem solving.

Most of what CS people do is to solve problems. Generally, problems that havn't been solved before.
A good approach is to solve any part you can and use that to attack the rest of the problem. Get your foot in the door. This is similar to solving multiple simultaneous equations.

Often you can't fully define the problem until you start solving it. The best requirement are a working program. Prototypes can lead to understanding the problem enough to lead to a solution. This is a process of stepwise refinement. Design it from the top down and build it from the bottom up.

Sometimes you need to change the point of view. For example, we have a big form that is used to fill in information about code inspections. We then looked at it from the point of view of different interfaces for different roles and uses. This leads to a very different solution. Describing the problem to someone else is another way to change perspective.