Algorithm
Algorithm
1. What is an Algorithm
An algorithm is a step-by-step set of instructions to solve a problem
It is like a recipe that tells you exactly what to do in a specific order.
Example:
Algorithm to make tea
Boil water
Add tea leaves to the boiling water
Add sugar and milk
Stir well
Strain and serve.
4. Representing Algorithm
Plain Text: Write the steps as a list (like in the tea example)
Flowchart: Use shapes and arrows to show the steps
Pseudocode: Write the steps in a simple coding-like language.
5. Examples of Algorithm
Find the largest number in a list
Start
Take a list of numbers
Compare each number to find the largest
Print the largest number
End
Check if a number is even or odd
Start
Input a number
If the number is divisible by 2, print "Even.
Otherwise, print "Odd.
End.
6. Types of Algorithm
Searching Algorithms: Find an item in a list
Example: Linear Search, Binary Search
Sorting Algorithms: Arrange items in a specific order
Example: Bubble Sort, Insertion Sort
Mathematical Algorithms: Solve mathematical problems
Example: Find the greatest common divisor (GCD).