**Tom Kelliher, CS17**

**Feb. 14, 1996**

See ``Pseudocoding Conventions,'' pp. 46--47

The process of decomposing (``refining'') a problem (the ``top'') into sub-problems (``down'' a level), each of which may themselves be treated as problems and, therefore, further decomposed (``stepwise'').

Examples:

- Planning a vacation
- Determining the factors of a given positive integer
- Finding the
**i**th largest number in a group of**n**numbers

Initial pseudocode:

read and verify number find and print number's factors print a message if number is prime

` read and verify number`:

let number = 0 while number < 1 begin print "Enter a positive integer: " read number end end_while

` find and print number's factors`:

let prime = TRUE let currentFactor = 2 let lastFactor = the square root of number truncated to an integer value while currentFactor <= lastFactor begin if number is evenly divisible by currentFactor begin print currentFactor let number = number / currentFactor end else let currentFactor = currentFactor + 1 end_if end end_while

` print a message if number is prime`:

if prime == TRUE print "Your number is prime" end_if

Initial pseudocode:

determine n determine i read the n numbers into a list arrange the n numbers in the list in descending order pick out the ith number in the list and print it

Work on further refinement in small groups

We won't cover structure charts

Do we need to look at flowcharts?

A computer program:

a sequence of a finite number of statements expressed in a programming language in a specific logical order which, when executed, produces the solution for a problem.

Compare * algorithm*

- Design errors --- occur during analysis, design, implementation
- Syntax errors --- caught during compilation
- warning messages
- error messages

- Run-Time errors

- Program verification --- ensure program meets user requirements
- Program testing --- demonstrate program correctness

Are these the same?

What types of errors will each uncover?

How would you adequately test

- a program which computes averages?
- a program which finds the
**i**th largest integer in**n**integers? - the software which controls the Space Shuttle?

Seemingly trivial, but important

Tue Feb 13 22:45:36 EST 1996