Program Design - NYU Computer Science Department

Download Report

Transcript Program Design - NYU Computer Science Department

Designing Computer
Programs
V22.0002
Deena Engel’s class
What is an algorithm?
•
•
•
•
•
An algorithm is the series of steps that can be
followed again and again for the same results.
Cooking receipe
Celtic knot designs, craft patterns, repeated
calculations
The steps in running a science experiement
Playing the notes of a musical scale or reading
a musical score to perform an entire piece of
music
Pseudo-code
• Pseudo-code is how we express what the steps would
be.
• For example, to find out all of the children’s favorite
colors in a kindergarten class:
• The program would prompt each child to select his/her
favorite color one at a time until all of the children have
selected red, yellow, blue, green, orange, or purple.
• Then the computer would print out a list of the colors
along with the number of children who selected each
one.
• Writing Pseudo-code is when we come up with a
program and look at it logically.
Refining a computer program
More examples of thinking of a programming
approach:
top-down design;
step-wise refinement (which is adding
steps);
adding comments