Lecture Notes 1/21/04 Program Design & Intro to Algorithms.
Published byModified over 4 years ago
Presentation on theme: "Lecture Notes 1/21/04 Program Design & Intro to Algorithms."— Presentation transcript:
Lecture Notes 1/21/04 Program Design & Intro to Algorithms
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
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.
Steps in Program Development 1. Define the problem Input Processing Output
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.
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.
Steps in Program Development 4. Test the algorithm for correctness Very important step!! Check for logical errors, create test data and test your algorithm.
Steps in Program Development 5. Code the algorithm into a specific programming language C, C++, Java, Fortran, Cobol, Basic, etc…
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)
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)
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.
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.
Structured Programming Structure Theorem Any computer program can be written using the following three control structures: * Sequence * Selection (If-Then-Else) * Repetition (DoWhile)
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.
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.