Algorithm
Algorithm
Objectives:
1. (Cognitive)
2. (Affective)
3. (Psychomotor)
An algorithm is the best way to represent the solution of a particular problem in a very
simple and efficient way. If we have an algorithm for a specific problem, then we can
implement it in any programming language, meaning that the algorithm is independent from
any programming languages.
Algorithm Design
• Problem definition
• Development of a model
• Specification of an Algorithm
• Designing an Algorithm
• Implementation of an Algorithm
• Program testing
• Documentation
Characteristics of Algorithms
• Algorithms halt in a finite amount of time. Algorithms should not run for infinity,
i.e., an algorithm must end at some point
Pseudocode
1. Always capitalize the initial word (often one of the main 6 constructs).
2. Have only one statement per line.
3. Indent to show hierarchy, improve readability, and show nested constructs.
4. Always end multiline sections using any of the END keywords (ENDIF, ENDWHILE, etc.).
5. Keep your statements programming language independent.
6. Use the naming domain of the problem, not that of the implementation.
E.g., “Append the last name to the first name” instead of “name = first+ last.”
7. Keep it simple, concise, and readable.
Following these rules help you generate readable pseudocode and be able to
recognize a not well-written one.
Step 1: Start
Step 2: get l,b values
Step 3: Calculate
A=l*b Step 4: Display
A
Step 5: Stop
BEGIN
Step 1: Start
Step 2: get a,b value
Step 3: check if(a>b) print a is greater
Step 4: else b is greater
Step 5: Stop
BEGIN
READ a,b
IF (a>b) THEN
DISPLAY a is greater
ELSE
DISPLAY b is greater
END IF
END
https://www.tutorialspoint.com/design_and_analysis_of_algorithms/design_and_analysis_of_algorithm
s_introduction.htm
https://www.brainkart.com/article/Examples-algorithms--pseudo-code,-flow-chart,-programming-
language_35900/