Program and Algorithm
Development and Analysis
• Program and Algorithm Development
• Pseudocodes and flowchart diagrams
• Debugging techniques and differentiation between
syntax, runtime and semantic errors
Program Development Steps (1)
1. Define the problem: carefully read problem statement and divide
into three separate components
• the inputs
• the outputs
• the processing steps to produce the required outputs
Copyright (c) 2007, Robertson L.A., Simple Program Design: A step-by-step approach. 5th ed. Boston: Thomson
Course Technology.
Program Development Steps (2)
2. Outline the solution (or user interface): break down problem into
smaller tasks/steps and establish a solution outline
• the major processing steps involved
• the major subtasks (if any)
• the user interface (if any)
• the major control structures (e.g. repetition loops)
• the major variables and record structures
• the mainline logic
Copyright (c) 2007, Robertson L.A., Simple Program Design: A step-by-step approach. 5th ed. Boston: Thomson
Course Technology.
Program Development Steps (3)
3. Develop the outline into an algorithm: a set of precise steps that
describe exactly the tasks to be performed and the order in which
they are to be carried out
• Pseudocode
• Flowcharts/Algorithm
Copyright (c) 2007, Robertson L.A., Simple Program Design: A step-by-step approach. 5th ed. Boston: Thomson
Course Technology.
Pseudocode
Definition:
• Step-by-step instructions in English language / using math (equations)
Structure:
• Single verb followed by two-word object
• Work from top to bottom
Keep in mind what operations a computer can perform
Receive information
Typical instructions to receive information are:
• Read student name
• Get system date
• Read number_1, number_2
• Get tax_code
Put out information
Typical instructions to output information are:
• Print ‘Program Completed’
• Write customer record to master file
• Put out name, address and postcode
• Output total_tax
• Display ‘End of data’
Operation
• Compute
• Calculate
• Add/subtract/divide/multiply
Example
Flowcharts
Definition:
• Graphical representation of program logic by a series of standard
geometric symbols and connecting lines
Flowcharts (con’t)
Copyright (c) 2007, Robertson L.A., Simple Program Design: A step-by-step approach. 5th ed. Boston: Thomson
Course Technology.
Flowcharts (con’t)
Copyright (c) 2007, Robertson L.A., Simple Program Design: A step-by-step approach. 5th ed. Boston: Thomson
Course Technology.
Program Development Steps (4-7)
4. Test the algorithm for correctness:
• identify test cases and walk through each step of the algorithm and check its logic
• use simple input cases that are valid for manual testing
• write down test cases and results in table
4. Code the algorithm into a specific programming language
5. Run the program on the computer
6. Document and maintain the program
Copyright (c) 2007, Robertson L.A., Simple Program Design: A step-by-step approach. 5th ed. Boston: Thomson
Course Technology.
Program Development Steps (1-7)
1. Define the problem
2. Outline the solution
3. Develop the outline into an algorithm
4. Test the algorithm for correctness
5. Code the algorithm into a specific programming language
6. Run the program on the computer
7. Document and maintain the program
Copyright (c) 2007, Robertson L.A., Simple Program Design: A step-by-step approach. 5th ed. Boston: Thomson
Course Technology.
Error Types
• Syntax errors: programmer writes instructions using incorrect syntax
Syntax is the set of rules that govern a language
• Runtime errors: occur while the program is being executed
e.g., division by zero, insufficient memory
• Semantic/logic errors: program runs smoothly but the output
obtained is not the solution you expect.
Copyright (c) 2021, Kong Q., Siauw T., Bayen A.M., Python Programming and Numerical Methods, Elsevier
Academic Press
Debugging
• Debugging: process of systematically removing errors
• Steps involved:
• Track the problem
• Reproduce it
• Automate and simplify
• Find possible infection origins
• Focus on most likely origins
• Isolate the infection chain
• Correct the defect
The Seven Steps of Debugging – Software Debugging [Link]
References / Reading
• Robertson L.A., Simple Program Design: A step-by-step approach
• Chapter 1: Program design
• Chapter 2: Pseudocode
• Chapter 3: Developing an algorithm
• Appendix 1: Flowcharts
• Kong Q., Siauw T., Bayen A.M., Python Programming and Numerical
Methods:
• Chapter 10: Debugging techniques
• [Link]
• The Seven Steps of Debugging – Software Debugging
[Link]