New 05-Algorithm Design and Problem Solving
New 05-Algorithm Design and Problem Solving
❑
Describe pseudocode and how it can be used to represent
algorithms.
❑
Describe flowcharts and how they can be used to represent
algorithms.
• Please refer to your textbook
• Chapter 8 Algorithms
PROBLEM SOLVING
1.4
PROBLEM SOLVING
• Problem solving is a process.
• Most strategies provide steps that help you identify the
problem and choose the best solution.
• Problem Solving steps
• Identify the problem
• Define the context of the problem
• Explore possible strategies
• Act on best solution
• Look back and learn
1.5
PROBLEM SOLVING
1.6
PROBLEM SOLVING
1.7
PROBLEM SOLVING
1.8
1.9
You will study algorithmic problem solving in this course
ALGORITHM
• The word algorithm comes from the name of the 9th century
Persian and Muslim mathematician Abu Abdullah
Muhammad ibn Musa Al-Khwarizmi.
• A computer program makes use of algorithms.
• An algorithm is a step-by-step method for solving a problem
or doing a task.
• A more formal definition: An algorithm is an ordered set of
unambiguous steps that produces a result and terminates in
a finite time.
1.10
ALGORITHM
1.13
ALGORITHM
• An algorithm can be represented using pseudocodes (or)
flowcharts.
• Pseudocodes is a method of describing computer algorithms
using a combination of natural language and programming
language. It is essentially an intermittent step towards the
development of the actual code. It allows the programmer
to formulate their thoughts on the organization and
sequence of a computer algorithm without the need for
actually following the exact coding syntax.
• Flowcharts are written with program flow from the top of a
page to the bottom. Each command is placed in a box of the
appropriate shape, and arrows are used to direct program
1.14
flow.
ALGORITHM
1.16
Three Constructs
PSEUDOCODES
1.17
PSEUDOCODES
1.24
Flowchart symbols Relational operators
FLOWCHARTS
Standard Symbols Used
Print
Start
Results A
On-Page
Input/Output Connector
Start Or Stop Process
Calculate Yes
Variables ? A1
1.26
A simple flowchart to read two
numbers and print their sum
FLOWCHARTS
Honour No
1
Student?
Yes
Read Courses
Taken
1
• Uses of flowcharts
▪ Flowcharts play a vital role in the programming of a
problem and are quite helpful in understanding the
logic of complicated and lengthy problems.
▪ Once the flowchart is drawn, it makes it easy to write
the program in any high level language.
▪ Often we see how flowcharts are helpful in explaining
the program to others.
• Uses of flowcharts
▪ Flow Charts document processes and interrelationships
of process steps
▪ FlowCharts identify actual and ideal paths where any
product or process flows
▪ Flow Charts are used to identify problems and potential
improvements
▪ FlowCharts can be completed on entire processes
assemblies with all components, one person or
component through a process, combinations of people
and machines, transactions following forms or other
documents, etc.
FLOWCHARTS
• Advantages of flowcharts
▪ Communication: Flowcharts are better way of communicating
the logic of a system to all concerned.
▪ Effective Analysis: With the help of flowchart, problem can be
analysed in more effective way.
▪ Proper Documentation: Program flowcharts serve as a good
program documentation, which is needed for various
purposes
▪ Efficient Coding: The flowcharts act as a guide or blueprint
during the systems analysis and program development phase.
▪ Proper Debugging: The flowchart helps in debugging process.
▪ Efficient Program Maintenance: The maintenance of
operating program becomes easy with the help of flowchart.
It helps the programmer to put efforts more efficiently on
that part.
FLOWCHARTS
• Disadvantages of flowcharts
▪ Complex Logic: Sometimes, the program logic is
quite complicated. In that case, flowchart becomes
complex and clumsy.
▪ Alterationsand Modifications: If alterations are
required the flowchart may require re-drawing
completely.
▪ Reproduction:
As the flowchart symbols cannot be
typed, reproduction of flowchart becomes a
problem.
The Essentials of what Is Done can easily be lost in
the technical details of how it is done.
Putting it all together
1.40
SUMMARY AND DISCUSSION
1.41