Algorithms
M3-R5.1 · Chapter 2: Algorithms and Flowcharts to Solve Problems · 4 min read
What is an Algorithm: An algorithm is a step-by-step procedure or set of rules to solve a specific problem. OR
Step by StepTextual representation of your Problem solution is known as An Algorithm
Characteristics of a Good Algorithm
- Well-Defined Inputs & Outputs – Takes input and produces a clear output.
- Definiteness – Each step must be clear and unambiguous.
- Finiteness – Must complete in a finite number of steps.
- Effectiveness – Each step must be simple enough to be executed.
- Independence – Should be language-independent, meaning it can be implemented in any programming language
Here algorithms and Flow chart to Add two numbers entered by the user.
Example: Algorithm for Exchanging Values of Two Variables
Step 1: Start Flow chart with Two Value
Step 2: Input two variables, say A and B
Step 3: Store the value of A in a temporary variable T
Step 4: Assign the value of B to A
Step 5: Assign the value of T (old value of A) to B
Step 6: Print the new values of A and B
Step 7: End