Professional Documents
Culture Documents
Ilovepdf Merged
Ilovepdf Merged
Algorithms are used for calculation, data processing, and many other fields.
Algorithms are generally created independent of underlying languages, i.e. an
algorithm can be implemented in more than one programming language.
Three reasons for using algorithms are efficiency, abstraction and reusability.
Efficiency: Certain types of problems, like sorting, occur often in
computing. Efficient algorithms must be used to solve such problems
considering the time and cost factor involved in each algorithm.
Pseudocode and flowcharts are structured ways to express algorithms that avoid
many ambiguities common in natural language statements, while remaining
independent of a particular implementation language.
A: Natural Language
1. Initialize sum
2. Repeat steps 3 and 4 ten times
3. Read number
4. Add number to sum
5. Print sum
B. Pseudo code
3. Read number
4. Sum ← sum + i
5. end for
6. Print Sum
C. Flowchart Representation
Start
Read Num
Yes
More?
No
Print Sum
Stop
B. Using Pseudocode
Exercises