POP Unit 1 Algorithm Flowchart
POP Unit 1 Algorithm Flowchart
Properties of algorithm:
1. Input: An algorithm can have zero or more clearly defined inputs.
2. Output: An algorithm must always produce at least one output.
3. Unambiguous/ Unambiguity: Every instruction in the algorithm must be clear
and straightforward. There should not be any confusion.
Ex:
Read a (clear instruction to read the variable a).
Read alone is unclear and has no meaning.
Ex:
while(true) {
. . . .
. . . .
}
Algorithm Program
Used in design phase. Used in implementation phase.
Use natural(human) language. Use programming language.
To write an algorithm person should Any programmer can write program
have domain knowledge. according to algorithm.
Not dependent on h/w and s/w. Dependent on hardware and software.
No need of h/w and s/w. Require h/w and s/w.
Used for analysis purpose. Used for testing purpose.
Summary:
Counting limits the number of iterations directly.
Sentinel values stop the loop when a specific condition is met.
Representation of algorithms
Common ways to represent an algorithm:
1. As a program
2. As a Flowchart
3. As a Pseudo Code
Flowchart
A flowchart is a graphical representation of an algorithm or a problem.
It is the first step towards solving a problem.
Flowcharts make it easier for everyone to understand how a process works.
2. Rectangle processing
YES NO
4. Diamond condition/ decision making
Step 1: Start
Step 2: Input a, b
Step 3: c = a + b
Step 4: print c
Step 5: end
Division flowchart: