OOPortal OOPortal

Structured Programming  «Prev  Next»
Lesson 4Pseudocode
Objective Describe and use pseudocode.

Pseudocode Algorithm

To illustrate the constructs of structured programming, we will consider several programs created in order to perform the task of going for a bicycle ride.
These programs will be written in pseudocode[1] rather than a specific programming language. As a matter of fact, it isn't intended that these programs be executed on a computer at all. They simply serve to demonstrate structured programming at a conceptual level.
Pseudocode is a rough outline of the logic of a program written in structured English rather than in a specific programming language. The advantage of using pseudocode is that it enables you to focus on the logic of a program rather than the implementation details. If a program is first written in pseudocode, it is usually much easier to re-write in the intended programming language.
Without knowing it, you've probably been using pseudcode for some time now. Here's a simple example courtesy of the shampoo bottle:

Wet hair

What is Pseudocode?

Pseudocode is an informal high-level description of the operating principle of a computer program or algorithm. It uses the structural conventions of a programming language, but is intended for human reading rather than machine reading. Pseudocode typically omits the details required for a machine to understand the algorithm, such as
  1. variable declarations,
  2. system-specific code and
  3. functions.
The programming language is augmented with natural language description details or with compact mathematical notation. The purpose of using pseudocode is for humans to gain an understanding of the tasks that need to be accomplished. Pseudocode is commonly used in textbooks and scientific publications that are documenting various algorithms, and also in the planning of computer program development, sketching out the structure of the program before the actual coding takes place.
Using pseudocode instead of a higher level programming language has the following advantages. The presentation of complex algorithms using all the details of any programming language clouds the students' understanding of the algorithms. Furthermore, the pseudocode should be understandable to someone versed in any highlevel language, which means it should avoid details specific to any one language as much as possible.
When designing algorithms, complexity analysis of algorithms, and computational complexity (analysis of problems). It does not cover other types of analyses, such as analysis of correctness. Our motivation for writingpseudocode was our inability to find algorithms that rigorously discuss complexity analysis of algorithms, yet is accessible to computer science students at mainstream universities such as University of Michigan. The majority of students have not studied calculus, which means that they are not comfortable with abstract mathematics and mathematical notation. The existing texts that we know of use notation that is fine for a mathematically sophisticated student, but is a bit terse for our student body. In the next lesson we will look at the first of the three control flow constructs of structured programming.
[1]Psuedocode: Form of structured English used to describe the logic of a program.