Ada Notes
All Topics (6)
- 1. Definition of Algorithm
- 2. Characteristics (Properties) of an Algorithm
- 3. Algorithm and Program Notes
- 4. Definition of Pseudocode
- 5. Comparison: Algorithm vs Pseudocode
- 6. Steps to Design an Algorithm
6. Steps to Design an Algorithm
Designing an algorithm is a structured process. Here are the key steps:
1. Understand the Problem
-
Carefully read and analyze the problem.
-
Identify inputs, outputs, and the desired result.
-
Make sure the requirements are clear before proceeding.
2. Decide Computation Means & Data Structure
-
Determine how the problem will be solved:
-
Use mathematical formulas, logical operations, or iteration.
-
-
Choose the appropriate data structures: arrays, lists, trees, etc.
3. Select Algorithm Design Technique
Common techniques include:
-
Divide and Conquer
-
Greedy Method
-
Dynamic Programming
-
Brute Force / Iterative Methods
4. Design the Algorithm
-
Write the step-by-step instructions clearly.
-
Ensure clarity, finiteness, effectiveness, and correctness.
5. Prove Correctness
-
Check the algorithm logically or mathematically.
-
Make sure it produces correct output for all possible inputs.
6. Analyze the Algorithm
-
Determine efficiency:
-
Time complexity (how long it takes)
-
Space complexity (how much memory it uses)
-
-
Identify potential bottlenecks or improvements.
7. Code the Algorithm
-
Implement the algorithm in a programming language.
-
Ensure the program matches the algorithm’s logic.
-
Test with multiple inputs for correctness.
Flow Diagram: Algorithm Design Process
↓
Decide Computation Means & Data Structure
↓
Select Algorithm Design Technique
↓
Design as Algorithm
↓
Prove Correctness
↓
Analyze the Algorithm
↓
Code the Algorithm