Chapter 3 Developing an algorithm. Objectives To introduce methods of analysing a problem and developing a solution To develop simple algorithms using.

Slides:



Advertisements
Similar presentations
Describing Process Specifications and Structured Decisions Systems Analysis and Design, 7e Kendall & Kendall 9 © 2008 Pearson Prentice Hall.
Advertisements

Programming Types of Testing.
Chapter 1 - An Introduction to Computers and Problem Solving
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Program Design Tool. 6 Basic Computer Operations Receive information Put out information Perform arithmetic Assign a value to variable (memory location)
Starting Out with C++, 3 rd Edition 1 Chapter 1. Introduction to Computers and Programming.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming The software development method algorithms.
Chapter 9 Describing Process Specifications and Structured Decisions
Logic and Algorithm. Developing an algorithm To help the initial analysis, the problem should be divided into 3 separate components: 1.Input: a list of.
Program Design and Development
Chapter 2: Input, Processing, and Output
Lecture Notes 1/21/04 Program Design & Intro to Algorithms.
Pseudocode.
Chapter 1 Program Design
Lecture Notes 8/30/05 Program Design & Intro to Algorithms.
Pseudocode.
Chapter 3 Planning Your Solution
Chapter 9 Structuring System Requirements: Logic Modeling
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
CC0002NI – Computer Programming Computer Programming Er. Saroj Sharan Regmi Week 7.
1 Shawlands Academy Higher Computing Software Development Unit.
Simple Program Design Third Edition A Step-by-Step Approach
Programming Lifecycle
1 The Software Development Process  Systems analysis  Systems design  Implementation  Testing  Documentation  Evaluation  Maintenance.
First Steps in Modularization Simple Program Design Third Edition A Step-by-Step Approach 8.
Describing Process Specifications and Structured Decisions Systems Analysis and Design, 7e Kendall & Kendall 9 © 2008 Pearson Prentice Hall.
Developing an Algorithm
Selection Control Structures Simple Program Design Third Edition A Step-by-Step Approach 4.
School of Computer Science & Information Technology G6DICP - Lecture 9 Software Development Techniques.
Describe the Program Development Cycle. Program Development Cycle The program development cycle is a series of steps programmers use to build computer.
Selection Control Structures. Simple Program Design, Fourth Edition Chapter 4 2 Objectives In this chapter you will be able to: Elaborate on the uses.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
Developing an Algorithm
CPS120 Introduction to Computer Programming The Programming Process.
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
Problem Solving using the Science of Computing MSE 2400 EaLiCaRA Spring 2015 Dr. Tom Way.
Chapter 1 Program design Objectives To describe the steps in the program development process To introduce the current program design methodology To introduce.
Pseudocode. Simple Program Design, Fourth Edition Chapter 2 2 Objectives In this chapter you will be able to: Introduce common words, keywords, and meaningful.
Pseudocode Simple Program Design Third Edition A Step-by-Step Approach 2.
Chapter 10 Software Engineering. Understand the software life cycle. Describe the development process models. Understand the concept of modularity in.
Cs413_design04.ppt Design and Software Development Design : to create a functional interface that has high usability Development : an organized approach.
Repetition Control Structures Simple Program Design Third Edition A Step-by-Step Approach 5.
Pseudocode Algorithms Using Sequence, Selection, and Repetition Simple Program Design Third Edition A Step-by-Step Approach 6.
First Steps in Modularization. Simple Program Design, Fourth Edition Chapter 8 2 Objectives In this chapter you will be able to: Introduce modularization.
Developing an Algorithm. Simple Program Design, Fourth Edition Chapter 3 2 Objectives In this chapter you will be able to: Introduce methods of analyzing.
The Software Development Process
Chapter 8 First steps in modularisation. Objectives To introduce modularisation as a means of dividing a problem into subtasks To present hierarchy charts.
First Steps in Modularization. Simple Program Design, Fourth Edition Chapter 8 2 Objectives In this chapter you will be able to: Introduce modularization.
1 Program Planning and Design Important stages before actual program is written.
Introduction to programming Carl Smith National Certificate Year 2 – Unit 4.
CSI 1340 Introduction to Computer Science II Chapter 1 Software Engineering Principles.
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
1 The Software Development Process ► Systems analysis ► Systems design ► Implementation ► Testing ► Documentation ► Evaluation ► Maintenance.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Program Design. Simple Program Design, Fourth Edition Chapter 1 2 Objectives In this chapter you will be able to: Describe the steps in the program development.
Chapter 7: Designing solutions to problems OCR Computing for A Level © Hodder Education 2009.
Chapter 2: Input, Processing, and Output
Chapter 1. Introduction to Computers and Programming
Chapter 2 : Data Flow Diagram
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Unit# 9: Computer Program Development
Program Design Introduction to Computer Programming By:
Lecture 09:Software Testing
Pseudocode algorithms using sequence, selection and repetition
Problem Solving Skill Area 305.1
Chapter 2: Input, Processing, and Output
WRITING AN ALGORITHM, PSEUDOCODE, AND FLOWCHART LESSON 2.
Chapter 5 Desk Checking/Dry Running.
Introduction to Pseudocode
Presentation transcript:

Chapter 3 Developing an algorithm

Objectives To introduce methods of analysing a problem and developing a solution To develop simple algorithms using the sequence control structure To introduce methods of manually checking the developed solution

3.1 Defining the problem

First step in the development of a computer program is defining the problem Carefully reading and rereading the problem until it is completely understood Additional information will need to be sought to help resolve and deficiencies in the problem specification

Defining the problem Problem should be divided into three separate components: 1.Input: a list of source data provided to the problem 2.Output: a list of the outputs required 3.Processing: a list of actions needed to produce the required outputs

Defining the problem When reading a problem statement, the input and output components are easily identified due to the use of descriptive words such as nouns and adjectives Processing component is also identified easily as the problem statement usually describes the processing steps as actions, using verbs and adverbs

Defining the problem Analyse the actual words used in the specification when dividing a problem into three separate components; divide them into those that are descriptive and those that imply action In some programming problems, the inputs, processes and output is not clearly defined. In such cases, it is best to concentrate on the outputs required

3.2 Designing a solution algorithm

Most challenging task in the life cycle of a program First attempt at designing a solution algorithm usually does not result in a finished product Pseudocode is useful in the trial-and- error process where it is relatively easy to add, alter or delete instructions

Designing a solution algorithm Reminder – if the algorithm is not correct, the program will never be correct It is important not to start coding until necessary steps of defining the problem and designing the solution algorithm have been completed

3.3 Checking the solution algorithm

After a solution algorithm has been established, it must be tested for correctness It is necessary because most major logic errors occur during the development of the algorithm (not detected then these errors can be passed on to the program) Easier to detect errors in pseudocode than in the corresponding program

Checking the solution algorithm Desk checking involves tracing through the logic of the algorithm with some chosen test data Walk through the logic of the algorithm exactly as a computer would, keeping track of all major variables values on a sheet of paper Helps detect errors early and allows the user to become familiar with the way the program runs

Checking the solution algorithm Selecting test data – Investigate program specification and choose simple test cases based on the requirement of the specification, not the algorithm – By doing this, the programmer will be able to concentrate on ‘what’ the program is supposed to do, not ‘how’ – To desk check the algorithm, only a few simple test cases that will follow the major parts of the algorithm logic is needed

Checking the solution algorithm Steps in desk checking an algorithm 1.Choose simple input test cases that are valid 2.Establish the expected result for each test case 3.Make a table on a piece of paper of the relevant variable names within the algorithm 4.Walk the first test case through the algorithm 5.Repeat the walk-through process using other test data 6.Check the expected result established in Step 2 matches the actual in Step 5

Summary A programmer must fully understand a problem before attempting to find a solution. The method suggested was to analyse the actual words used in the specification with the aim of dividing the problem into three separate components: input, output and processing.

Summary After initial analysis of the problem, the programmer must attempt to find a solution and express this solution as an algorithm. To do this, the programmer must use the defining diagram, the correct pseudocode statement and the three basic control structures. Check the algorithm for correctness by tracing through the algorithm step by step.