0% found this document useful (0 votes)
6 views

Chapter 7

The document outlines the Program Development Life Cycle, which consists of five stages: Analysis, Design, Coding, Testing, and Maintenance. It emphasizes the importance of problem decomposition, formal documentation methods like flowcharts and pseudocode, and various testing data types to ensure program functionality and reliability. Additionally, it discusses the structure of computer systems and subsystems, as well as validation and verification processes for data accuracy.

Uploaded by

thediscordmonke
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Chapter 7

The document outlines the Program Development Life Cycle, which consists of five stages: Analysis, Design, Coding, Testing, and Maintenance. It emphasizes the importance of problem decomposition, formal documentation methods like flowcharts and pseudocode, and various testing data types to ensure program functionality and reliability. Additionally, it discusses the structure of computer systems and subsystems, as well as validation and verification processes for data accuracy.

Uploaded by

thediscordmonke
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 36

Algorithm Design and

Problem Solving
By Amna Javed
Program Development Life Cycle
Program Development Life Cycle

the stages a computer program undergoes, from initial creation to


deployment and execution
The program development cycle is divided into five stages:
1. Analysis
2. Design
3. Coding
4. Testing
5. Maintenance
Analysis

• Before solving a problem, it is essential to define and document the problem clearly,
known as the "requirements specification" for the program.
• The analysis stage involves using tools like abstraction and decomposition to
identify the specific requirements for the program.
• Abstraction focuses on the essential elements needed for the solution while
eliminating unnecessary details and information.
• Decomposition involves breaking down complex problems into smaller, more
manageable parts that can be solved individually.
• Daily tasks can be decomposed into constituent parts for easier understanding and
solving
Design

• The program specification derived from the analysis stage is


used as a guide for program development.
• During the design stage, the programmer should clearly
understand the tasks to be completed, the methods for
performing each task, and how the tasks will work together.
• Documentation methods such as structure charts,
flowcharts, and pseudocode can be used to document the
program's design formally
Coding

• The program or set of programs is developed based on the design.


• Each module of the program is written using a suitable programming
language.
• Testing is conducted to ensure that each module functions correctly.
• Iterative testing is performed, which involves conducting modular
tests, making code amendments if necessary, and repeating tests
until the module meets the required functionality.
Testing

• The completed program or set of programs is executed multiple times


using various test data sets.
• This testing process ensures that all the tasks within the program work
together as specified in the program design.
• Running the program with different test data can identify and address
potential issues and errors.
• The testing phase aims to verify the overall functionality and
performance of the program by evaluating its behavior with various
inputs.
Computer System & Sub System

• A computer system is made up of software, data, hardware, communications


and people.
• Each computer can be divided into a set of sub systems
• Each sub system can be further divided into sub systems and so on until each
subsystem just performs a single action
• Computer system can be very large or very small or any size in b/w
• E.g. Alarm is a very small system while weather forecast is part of a very large
system
Computer System & Sub System

Top Down Design:


• Each computer can be divided into a set of sub systems and each sub system
can be further divided into sub systems and so on until each subsystem just
performs a single action
• Effective way of designing a computer system to provide a solution to a problem
since each part is broken down into smaller more manageable parts (stepwise
refinement)
• When large systems are being developed, programmers can independently work
on one sub system of the same system saving development and testing time
Decomposing a Problem

• Any problem using computer to be solved needs to be


decomposed into its components.
• The component parts of any system are:
• Inputs
• Processes
• Outputs
• Storage
Decomposing a Problem

Example 1: An Alarm App


Design (Methods)

The use of formal methods enables the process to be clearly


shown for others to understand the proposed solution. Some
methods are as follow:
1. Structure diagram
2. Flowcharts
3. Pseudo code
Structure Diagram

The breaking down of a computer system


into sub-systems, then breaking each sub-
system into smaller sub-systems until each
one only performs a single action. A
structure diagram diagrammatically
represents a top-down design
Example
Flowcharts

• A flowchart shows diagrammatically the


steps required to complete a task and the
order that they are to be performed
• These steps together with the order are called
an Algorithm
Flowcharts
Past Paper Question

Draw a flowchart to check if a rider’s height is


more the requirement (1.2). It then counts until
the accepted riders are 8. After they are 8, it
outputs the number of rejected riders and tells
the rest that they are ready to go!
Solution
Pseudo code

• Verbal representation of an algorithm (a process or set


of steps)
• Describe algorithm using English key words similar to high
level language
• Data items are given meaningful names
• Not bound by the strict syntax rules of any programming
language
Pseudo code

• Assignment statement:
• Each variable is assigned using a left arrow.
• [VARIABLE NAME] <---- [Value to be assigned]

Activity 7.3
Pseudo code

• Declaration & Usage of Variables & Constants


• Variable – Store of data which changes during execution of the program (due to user input)
DECLARE [Variable Name] : [DATATYPE OF VARIABLE]
• Constant – Store of data that remains the same during the execution of the program

• Basic Data Types


• Integer – Whole Number e.g. 2; 8; 100
• Real – Decimal Number e.g. 7.00; 5.64
• Char – Single Character e.g. a; Y
• String – Multiple Characters (Text) e.g. ZNotes; COOL
• Boolean – Only 2 Values e.g. True/False; Yes/No; 0/1
Pseudo code

• Input & Output (READ & PRINT) – Used to receive and


display data to the user respectively. (It is recommended to
use input and output commands)
• Array:
• Array is similar to variable but it can store multiple values of same
datatype under single name
• DECLARE [ARRAYNAME] : ARRAY [Lower Limit : Upper Limit ] OF
[DATATYPE]
Pseudo code for Conditional
Statements
(IF…THEN…ELSE…ENDIF )
A condition that can be
T/F A choice b/w diff values
Pseudo code for Conditional
Statements
(IF…THEN…ELSE…ENDIF )

Activity 7.4 & 7.5


Pseudo code for Conditional
Statements
(iteration & loop Structures)
• When some actions performed as part of an algorithm need repeating this is
called iteration
• Loop structures are used to perform iteration
• Pseudo code involves these three types of loop structure:
1. For…. To…. Next
2. Repeat….. Until
3. While…. Do
EndWhile
Example from book (pg. 269)
Pseudo code for Input/output
Statements
Purpose of an Algorithm

Activity 7.6
Standard Methods of Solution

1. Totalling:
2. Counting
3. Max, Min, & Avg
4. Linear Search
5. Bubble Sort
Validation

Ensures data meets certain criteria and is reasonable such as:


• Range check
• Length check
• Type check
• Presence check
• Format check/ Check Digit
Verification

Ensures data is accurate and reliable. There are two methods of


Verification:
1. Double Entry
2. Screen/Visual check
Test Data

• Test data refers to input values used to evaluate and assess the
functionality and performance of a computer program or system.
• It helps identify errors and assess how the program handles different
scenarios
• There are four types of Data Sets:
1. Normal Data
2. Abnormal Data
3. Extreme Data
4. Boundary Data
Test Data

Normal Data:
• Normal data is the test data which accepts values in acceptible range
of values of the program
• Normal data should be used to work through the solution to find the
actual result(s) and see if they are the same as the expected result(s)
• e.g. in a program where only whole number values ranging from 0 to
100 (inclusive) are accepted, normal test data will be : 23, 54, 64 , 2
and 100
Test Data

Abnormal Data:
• Test data that would be rejected by the solution as not
suitable, if the solution is working properly is called abnormal
test data / erroneous test data.
• e.g. in a program where only whole number values ranging
from 0 to 100 (inclusive) are accepted, abnormal data will be:
-1, 151, 200, 67.2, “Sixty-Two” and -520
Test Data

Extreme Data:
• Extreme data are the largest and smallest values that normal
data can take
• e.g. in a program where only whole number values ranging
from 0 to 100 (inclusive) are accepted, extreme data will be:
0 and 100
Test Data

Boundary Data:
• This is used to establish where the largest and smallest values occur
• At each boundary two values are required: one value is accepted
and the other value is rejected.
• e.g. in a program where only whole number values ranging from 0 to
100 (inclusive) are accepted, one example of boundary data will be:
100 and 101. 100 will be accepted and 101 will not be accepted
Trace Tables

• A trace table is utilized to document the outcomes of every


step in an algorithm. It is employed to record the variable's
value each time it undergoes a change.
• A dry run refers to the manual process of systematically
executing an algorithm by following each step in sequence.
• A trace table is set up with a column for each variable and a
column for any output

You might also like