Download presentation

Presentation is loading. Please wait.

1
Lecture Notes 1/21/04 Program Design & Intro to Algorithms

2
Program Development Define the problem Outline the solution Develop the outline into an algorithm Test the algorithm for correctness Code the algorithm into a specific programming language Run the program on the computer –test and debug Document and maintain the program

3
Algorithms * Informally - a general method for solving a problem; a recipe. *According to Webster.. al.go.rithm - a rule or procedure for solving a mathematical problem that frequently involves repetition of an operation.

4
Algorithms - Example How do you start your car?

5
Algorithms - Example

6
Steps in Program Development 1. Define the problem Input Processing Output

7
Steps in Program Development 2. Outline the solution This is a rough draft of the solution. The outline may include: Major processing steps involved. Major subtasks Major Control Structures Major variables and record structures The mainline logic.

8
Steps in Program Development 3. Develop an outline into an algorithm The algorithm represents the precise steps to be taken and the order in which they are to be carried out. For the purpose of this class, algorithm= pseudocode.

9
Steps in Program Development 4. Test the algorithm for correctness Very important step!! Check for logical errors, create test data and test your algorithm.

10
Steps in Program Development Example:

11
Steps in Program Development 5. Code the algorithm into a specific programming language C, C++, Java, Fortran, Cobol, Basic, etc…

12
Steps in Program Development 6. Run the program on a computer – test and debug The most fun and the most frustrating part of the program development. Two main types of errors: Syntax errors (the program will not run) Logic errors (the program will run but will not produce correct results)

13
Steps in Program Development 7. Document and maintain the program This is NOT the last step. You should document throughout the process of developing your program. External documentation (algorithm, test data, etc…) Internal documentation (commenting your code)

14
Structured Programming Top down development: Look at the problem as a whole Outline general solution Break down into main components Functional decomposition This systematic, disciplined approach to program design results in a higher precision of programming.

15
Structured Programming Modular Design Subtasks are often repeated. It is useful to modularize them so that we don’t have to reinvent the wheel every time we need to do the same subtask.

16
Structured Programming Structure Theorem Any computer program can be written using the following three control structures: * Sequence * Selection (If-Then-Else) * Repetition (DoWhile)

17
Algorithms Algorithm is required to be: * Well defined -- it is clearly and unambiguously specified. * Effective -- its steps are executable. * Finite -- it terminates after a bounded number of steps. Must produce a correct solution 100% of the time.

18
Pseudocode We textbook establishes the standard for the pseudocode which we will follow in this class: - Statements are written in simple English; - Each instruction is written on a separate line - Each set of instructions is written from top to bottom, with only one entry and one exit - Groups of statements may be formed into modules, and that group given a name.

19
Summary

20
Homework Download a copy of the syllabus and read it. Write an algorithm “How to register for a class at UNR” Read Chapter 1 and 2 in “Simple Program Design”

Similar presentations

© 2019 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google