SlideShare a Scribd company logo
Algorithm design and problem
solving
PROGRAM DEVELOPMENT LIFE
CYCLE(PDLC )
The program development life cycle is divided into five stages:
Analysis
Design
Coding
Testing
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 and iterative testing
‱ 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 behaviour with various
inputs.
Decomposition
This is the act of breaking down a large problem into smaller, clear,
manageable and understandable sub-parts. Sub-parts can be divided until they
are easily solvable and cannot be broken down any further. An example of
decomposition could be getting ready in the morning to go to school
Step 1: Wake up
Step 2: Brush teeth
Step 3: Get breakfast
Step 4: Put clothes on
Step 5: Make sure the bag and school supplies are ready
Step 6: Find transport to school e.g. walk, bus, car, bike, etc
Example 1:
These steps could be further subdivided, for example, “Step 2: Get
breakfast” would entail:
Step 2.1 Get a bowl
Step 2.2 Get cereal
Step 2.3 Get milk
Step 2.4 Get a spoon
Step 2.5 Put cereal in a bowl
And so on

Methods used to
design and construct
a solution to a
problem
❑ Structure diagrams
❑ Flowcharts
❑ Pseudocode
Example 2: Structure diagrams
Consider the alarm application for a smart phones. It contain
three sub-systems – setting the alarm, checking alarm time,
sounding alarm
Flowcharts
A flowchart show graphical /
diagrammatically the steps required to
complete a task the order that they are to
be performed. The steps together with the
order, are called an algorithm.
FLOWCHARTS SYMBOL
Example 3: Concert
ticket Sales
Tickets are sold for a concert at $20 each, if
10 tickets are bought then the discount is
10%, if 20 tickets are bought is 20 %. No
more than 25 tickets can be bought in a single
transaction. This is flowchart an algorithm to
calculate the cost of buying a given number of
tickets.
PSEUDOCODE
Pseudocode is a simple method of showing an algorithm. It describe what
the algorithm does by using English keywords that are very similar to
those used in a high-level programming language.
Example of pseudocode assignment statements:
Cost  10 Cost has the value 10
Price  Cost * 2 Price has the value 20
Tax Price * 0.12 Tax has the value 2.4
Selling Price  Price + Tax Selling Price has the value 22.4
Gender  “M” Gender has value M
Choose False Chosen the value False
Pseudocode for Conditional
Statements
Two Types of conditional Statement:
1. Condition that can be true or false as: IF ..THEN 
ELSE
END IF
IF AGE > 18
THEN
OUTPUT “ELIGIBLE FOR VOTING
ELSE
OUTPUT “NOT ELIGIBLE FOR VOTING
ENDIF
CONT..
2. A choice between several different values, such as: CASE
OF
OTHERWISE
.ENDCASE
CASE OF Grade
“A” : OUTPUT “Excellent”
“B”: OUTPUT “Good”
“C”: OUTPUT “Average”
OTHERWISE, OUTPUT “Improvement is needed
ENDCASE
IF..THEN..ELSE..ENDIF
For an IF condition the THEN path is followed if the condition is true and
the ELSE path is followed if the condition is false. There may or may not
be an ELSE path. The end of the statement is shown by ENDIF.
There are different ways that an IF condition can be set up:
IF (Height >1) OR (Weight > 20) AND (Age < 70) AND (Age > 5)
THEN
OUTPUT “You can ride”
ELSE
OUTPUT “Too small, to young or old to ride”
ENDIF
Example: CASE
OF
OTHERWISE
ENDCASE
CASE OF Choice
1: Answer  Num1 + Num2
2: Answer  Num1 – Num2
3: Answer  Num1 * Num2
4. Answer  Num1 / Num2
OTHERWISE, OUTPUT “Please enter a valid choice”
ENDCASE
Pseudocode for iteration
Some action performed as part of an algorithm need repeating this
is called iteration. Loop structure are used to perform the iteration.
‱ FOR 
TO
NEXT ---> A set number of repetitions
‱ REPEAT 
UNTIL ---> A repetition, where the number of repeats
is not known, that is completed at least once.
‱ WHILE..DO..ENDWHILE ---> A repetition, where the number of
repeats is not known, that may never be completed.
All types of loops
A FOR 
NEXT loop
A WHILE

DO
ENDWHILE loop
A REPEAT
.UNTIL loop
THANK YOU
Q&A

More Related Content

Similar to Algorithm Design and Problem Solving.pdf (20)

PPTX
s-INTRODUCTION TO PROBLEM SOLVING PPT.pptx
ShamithRai
 
PPT
Ch1 principles of software development
Hattori Sidek
 
PDF
Algorithm.pdf
MIT,Imphal
 
PPTX
Data Structures_Introduction to algorithms.pptx
RushaliDeshmukh2
 
PPT
Comp102 lec 1
Fraz Bakhsh
 
PPTX
Software develop....
GCWUS
 
PPT
Problem Solving Techniques
Ashesh R
 
PPTX
PCCF UNIT 1.pptx
DivyaKS12
 
PPTX
Cse
Yashitha11
 
PPT
Intro to prog
Chaffey College
 
PPT
Proble, Solving & Automation
Janani Satheshkumar
 
PPT
UNIT- 3-FOC.ppt
KalaivaniRMECLectCSE
 
PPTX
10 lesson8
Mary Grace Uminga
 
PPTX
Algorithm & data structure lec2
Abdul Khan
 
PPTX
introduction to computing & programming
Kalai Selvi
 
PPTX
Programming C ppt for learning foundations
ssuser65733f
 
PPTX
3 Program Development Life Cycle.aaaaapptx
EG20910848921ISAACDU
 
PPTX
Introduction to computer programming
Sangheethaa Sukumaran
 
PDF
Pseudocode By ZAK
Tabsheer Hasan
 
PPTX
pseudocode Note(IGCSE Computer Sciences)
MKKhaing
 
s-INTRODUCTION TO PROBLEM SOLVING PPT.pptx
ShamithRai
 
Ch1 principles of software development
Hattori Sidek
 
Algorithm.pdf
MIT,Imphal
 
Data Structures_Introduction to algorithms.pptx
RushaliDeshmukh2
 
Comp102 lec 1
Fraz Bakhsh
 
Software develop....
GCWUS
 
Problem Solving Techniques
Ashesh R
 
PCCF UNIT 1.pptx
DivyaKS12
 
Cse
Yashitha11
 
Intro to prog
Chaffey College
 
Proble, Solving & Automation
Janani Satheshkumar
 
UNIT- 3-FOC.ppt
KalaivaniRMECLectCSE
 
10 lesson8
Mary Grace Uminga
 
Algorithm & data structure lec2
Abdul Khan
 
introduction to computing & programming
Kalai Selvi
 
Programming C ppt for learning foundations
ssuser65733f
 
3 Program Development Life Cycle.aaaaapptx
EG20910848921ISAACDU
 
Introduction to computer programming
Sangheethaa Sukumaran
 
Pseudocode By ZAK
Tabsheer Hasan
 
pseudocode Note(IGCSE Computer Sciences)
MKKhaing
 

Recently uploaded (20)

PPTX
CapCut Pro PC Crack Latest Version Free Free
josanj305
 
PDF
Kubernetes - Architecture & Components.pdf
geethak285
 
PDF
Simplify Your FME Flow Setup: Fault-Tolerant Deployment Made Easy with Packer...
Safe Software
 
PDF
GDG Cloud Southlake #44: Eyal Bukchin: Tightening the Kubernetes Feedback Loo...
James Anderson
 
PDF
Optimizing the trajectory of a wheel loader working in short loading cycles
Reno Filla
 
PDF
Darley - FIRST Copenhagen Lightning Talk (2025-06-26) Epochalypse 2038 - Time...
treyka
 
PDF
Automating the Geo-Referencing of Historic Aerial Photography in Flanders
Safe Software
 
PDF
DoS Attack vs DDoS Attack_ The Silent Wars of the Internet.pdf
CyberPro Magazine
 
PDF
Quantum Threats Are Closer Than You Think – Act Now to Stay Secure
WSO2
 
PDF
Pipeline Industry IoT - Real Time Data Monitoring
Safe Software
 
PDF
How to Comply With Saudi Arabia’s National Cybersecurity Regulations.pdf
Bluechip Advanced Technologies
 
PDF
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 
PDF
“Scaling i.MX Applications Processors’ Native Edge AI with Discrete AI Accele...
Edge AI and Vision Alliance
 
PDF
FME as an Orchestration Tool with Principles From Data Gravity
Safe Software
 
PDF
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 
PDF
Bridging CAD, IBM TRIRIGA & GIS with FME: The Portland Public Schools Case
Safe Software
 
PPTX
Mastering Authorization: Integrating Authentication and Authorization Data in...
Hitachi, Ltd. OSS Solution Center.
 
PDF
''Taming Explosive Growth: Building Resilience in a Hyper-Scaled Financial Pl...
Fwdays
 
PDF
TrustArc Webinar - Navigating APAC Data Privacy Laws: Compliance & Challenges
TrustArc
 
PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Poster...
Michele Kryston
 
CapCut Pro PC Crack Latest Version Free Free
josanj305
 
Kubernetes - Architecture & Components.pdf
geethak285
 
Simplify Your FME Flow Setup: Fault-Tolerant Deployment Made Easy with Packer...
Safe Software
 
GDG Cloud Southlake #44: Eyal Bukchin: Tightening the Kubernetes Feedback Loo...
James Anderson
 
Optimizing the trajectory of a wheel loader working in short loading cycles
Reno Filla
 
Darley - FIRST Copenhagen Lightning Talk (2025-06-26) Epochalypse 2038 - Time...
treyka
 
Automating the Geo-Referencing of Historic Aerial Photography in Flanders
Safe Software
 
DoS Attack vs DDoS Attack_ The Silent Wars of the Internet.pdf
CyberPro Magazine
 
Quantum Threats Are Closer Than You Think – Act Now to Stay Secure
WSO2
 
Pipeline Industry IoT - Real Time Data Monitoring
Safe Software
 
How to Comply With Saudi Arabia’s National Cybersecurity Regulations.pdf
Bluechip Advanced Technologies
 
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 
“Scaling i.MX Applications Processors’ Native Edge AI with Discrete AI Accele...
Edge AI and Vision Alliance
 
FME as an Orchestration Tool with Principles From Data Gravity
Safe Software
 
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 
Bridging CAD, IBM TRIRIGA & GIS with FME: The Portland Public Schools Case
Safe Software
 
Mastering Authorization: Integrating Authentication and Authorization Data in...
Hitachi, Ltd. OSS Solution Center.
 
''Taming Explosive Growth: Building Resilience in a Hyper-Scaled Financial Pl...
Fwdays
 
TrustArc Webinar - Navigating APAC Data Privacy Laws: Compliance & Challenges
TrustArc
 
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Poster...
Michele Kryston
 
Ad

Algorithm Design and Problem Solving.pdf

  • 1. Algorithm design and problem solving
  • 2. PROGRAM DEVELOPMENT LIFE CYCLE(PDLC ) The program development life cycle is divided into five stages: Analysis Design Coding Testing Maintenance
  • 3. 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.
  • 4. 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.
  • 5. Coding and iterative testing ‱ 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.
  • 6. 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 behaviour with various inputs.
  • 7. Decomposition This is the act of breaking down a large problem into smaller, clear, manageable and understandable sub-parts. Sub-parts can be divided until they are easily solvable and cannot be broken down any further. An example of decomposition could be getting ready in the morning to go to school Step 1: Wake up Step 2: Brush teeth Step 3: Get breakfast Step 4: Put clothes on Step 5: Make sure the bag and school supplies are ready Step 6: Find transport to school e.g. walk, bus, car, bike, etc
  • 8. Example 1: These steps could be further subdivided, for example, “Step 2: Get breakfast” would entail: Step 2.1 Get a bowl Step 2.2 Get cereal Step 2.3 Get milk Step 2.4 Get a spoon Step 2.5 Put cereal in a bowl And so on

  • 9. Methods used to design and construct a solution to a problem ❑ Structure diagrams ❑ Flowcharts ❑ Pseudocode
  • 10. Example 2: Structure diagrams Consider the alarm application for a smart phones. It contain three sub-systems – setting the alarm, checking alarm time, sounding alarm
  • 11. Flowcharts A flowchart show graphical / diagrammatically the steps required to complete a task the order that they are to be performed. The steps together with the order, are called an algorithm.
  • 13. Example 3: Concert ticket Sales Tickets are sold for a concert at $20 each, if 10 tickets are bought then the discount is 10%, if 20 tickets are bought is 20 %. No more than 25 tickets can be bought in a single transaction. This is flowchart an algorithm to calculate the cost of buying a given number of tickets.
  • 14. PSEUDOCODE Pseudocode is a simple method of showing an algorithm. It describe what the algorithm does by using English keywords that are very similar to those used in a high-level programming language. Example of pseudocode assignment statements: Cost  10 Cost has the value 10 Price  Cost * 2 Price has the value 20 Tax Price * 0.12 Tax has the value 2.4 Selling Price  Price + Tax Selling Price has the value 22.4 Gender  “M” Gender has value M Choose False Chosen the value False
  • 15. Pseudocode for Conditional Statements Two Types of conditional Statement: 1. Condition that can be true or false as: IF ..THEN 
ELSE
END IF IF AGE > 18 THEN OUTPUT “ELIGIBLE FOR VOTING ELSE OUTPUT “NOT ELIGIBLE FOR VOTING ENDIF
  • 16. CONT.. 2. A choice between several different values, such as: CASE OF
OTHERWISE
.ENDCASE CASE OF Grade “A” : OUTPUT “Excellent” “B”: OUTPUT “Good” “C”: OUTPUT “Average” OTHERWISE, OUTPUT “Improvement is needed ENDCASE
  • 17. IF..THEN..ELSE..ENDIF For an IF condition the THEN path is followed if the condition is true and the ELSE path is followed if the condition is false. There may or may not be an ELSE path. The end of the statement is shown by ENDIF. There are different ways that an IF condition can be set up: IF (Height >1) OR (Weight > 20) AND (Age < 70) AND (Age > 5) THEN OUTPUT “You can ride” ELSE OUTPUT “Too small, to young or old to ride” ENDIF
  • 18. Example: CASE OF
OTHERWISE
ENDCASE CASE OF Choice 1: Answer  Num1 + Num2 2: Answer  Num1 – Num2 3: Answer  Num1 * Num2 4. Answer  Num1 / Num2 OTHERWISE, OUTPUT “Please enter a valid choice” ENDCASE
  • 19. Pseudocode for iteration Some action performed as part of an algorithm need repeating this is called iteration. Loop structure are used to perform the iteration. ‱ FOR 
TO
NEXT ---> A set number of repetitions ‱ REPEAT 
UNTIL ---> A repetition, where the number of repeats is not known, that is completed at least once. ‱ WHILE..DO..ENDWHILE ---> A repetition, where the number of repeats is not known, that may never be completed.
  • 20. All types of loops A FOR 
NEXT loop A WHILE 
DO
ENDWHILE loop A REPEAT
.UNTIL loop