Introduction to Algorithms - JSS 1
TOPIC: Introduction to Algorithms
CLASS: JSS 1
Introduction to Algorithms
- Define an algorithm in plain language.
- Identify the key characteristics of a good algorithm.
- Relate algorithms to everyday human activities.
- Write down simple, working algorithms using standard sequential steps.
1. Meaning of an Algorithm
In our last lesson, we learned about computational thinking and how decomposition allows us to break down huge challenges into bite-sized tasks. Once a problem has been broken down, the next direct step is to plan a clear, orderly path to solve it. This orderly path is called an algorithm.
Think of an algorithm like a recipe in a cookbook. If you do not follow the recipe steps in the exact order they are listed, your food will not taste right. In the exact same way, a computer needs clear, ordered instructions to execute its tasks without producing errors.
2. Key Characteristics of a Good Algorithm
Not just any list of sentences qualifies as a good algorithm. To work reliably for humans or computers, an algorithm must exhibit these structural properties:
| Characteristic | What It Rules |
|---|---|
| Clear and Unambiguous | Every single step must be completely clear. There should be no guesswork involved. |
| Input Defined | It must clearly state what materials or values you need before you start. |
| Output Defined | It must clearly state what the final expected result will be. |
| Finite (Has an End) | The instructions must eventually stop. It cannot run in an endless loop forever. |
| Feasible | The instructions must be realistic and possible to execute using available resources. |
3. Everyday Real-World Algorithms
Humans use algorithms all day long without even realizing it. From brushing your teeth in the morning to checking your school exam results, you are following hidden algorithms embedded in your daily routines.
Let's look at four practical, simple algorithms written out in chronological sequence:
Algorithm 1: Boiling an Egg (Everyday Task)
This algorithm details the exact procedural steps needed to cook a hard-boiled egg safely.
Step 2: Gather materials (raw egg, water, pot, stove)
Step 3: Put water into the pot
Step 4: Place the raw egg gently inside the pot
Step 5: Turn on the stove heat and place the pot on it
Step 6: Wait for the water to boil for 10 minutes
Step 7: Turn off the stove heat
Step 8: Remove the egg from the hot water carefully
Step 9: Output: A cooked, hard-boiled egg
Step 10: Stop
Algorithm 2: Adding Two Numbers Together (Mathematical Task)
This algorithm takes two separate numeric values provided by a user, combines them, and shows the sum.
Step 2: Get the first number (let's call it A)
Step 3: Get the second number (let's call it B)
Step 4: Add number A and number B together (Sum = A + B)
Step 5: Display or print the value of Sum
Step 6: Stop
Algorithm 3: Buying Airtime from an ATM (Digital Device Task)
This algorithm outlines the exact logic path used by bank automated teller machines to process airtime purchases.
Step 2: Insert your ATM card into the machine slot
Step 3: Type in your secret 4-digit PIN
Step 4: Select "Airtime Recharge" from the screen options
Step 5: Type in your mobile phone number
Step 6: Type in the amount of airtime you want to purchase
Step 7: Collect your ATM card and transaction receipt
Step 8: Output: Airtime successfully credited to your phone network
Step 9: Stop
Algorithm 4: Deciding What to Wear Based on Weather (Logical Decision Task)
This simple algorithm introduces conditions, helping a student pick out their morning dress items based on current external conditions.
Step 2: Look outside at the morning sky
Step 3: Check if rain is actively falling
Step 4: IF it is raining, pick your raincoat and umbrella
Step 5: ELSE (if it is not raining), pick your normal school uniform blazer
Step 6: Put on the chosen clothing items itemized above
Step 7: Stop
4. Guidelines for Writing Simple Algorithms
When you sit down to design your own custom algorithm for your computer science projects, always stick to these three basic structural building blocks:
- Always start and stop cleanly: Your very first instruction must always say "Start" and your absolute final instruction must say "Stop".
- Use simple language: Write your steps in plain English (often called Pseudocode). Don't confuse yourself with hard programming codes yet.
- One action per step: Do not group multiple distinct instructions together into a single point. Keep each line limited to one straightforward action.
Comments
Post a Comment