8785_Week Two Lesson Note
8785_Week Two Lesson Note
CLASS: SS 2
WEEK: TWO
TOPIC: ALGORITHM
What is an algorithm?
An algorithm is a set of instructions designed to solve a specific problem or accomplish a particular task.
It is a step-by-step procedure for solving a problem or completing a task, typically involving a finite
sequence of logical or mathematical operations.
In computer science, algorithms are often used to solve problems that are too complex for humans to
solve manually, such as sorting large amounts of data, searching for information in a database, or
calculating mathematical functions.
Algorithms can take many forms, from simple procedures like sorting a list of numbers to complex
machine learning algorithms that can recognize patterns and make predictions based on data. They are
often represented using pseudocode, flowcharts, or programming code.
FUNCTIONS OF ALGORITHMS
The functions of algorithms can vary depending on their specific purpose and application. Here are some
general functions of algorithms:
- Solving problems: Algorithms can be used to solve a wide range of problems, from simple tasks
like sorting a list of numbers to complex problems like calculating the most efficient route
between multiple locations.
- Automating tasks: Algorithms can be used to automate tasks that are repetitive or time-
consuming, such as data entry or image processing.
- Data analysis: Algorithms can be used to analyze large amounts of data and identify patterns or
trends that would be difficult or impossible to detect manually.
- Decision-making: Algorithms can be used to make decisions based on data or other inputs, such
as recommending products to customers or identifying potential risks in financial investments.
- Optimization: Algorithms can be used to optimize processes or systems, such as finding the
most efficient way to distribute resources or minimize waste.
Overall, the functions of algorithms are diverse and can be applied in a wide range of fields and
industries, from computer science and engineering to finance and healthcare. The main goal of an
algorithm is to provide a systematic and efficient approach to problem-solving or task completion.
CHARACTERISTICS OF ALGORITHMS
Algorithms have several characteristics that define their nature and usefulness in problem-solving. Some
of the most important characteristics of algorithms are:
- Clear and unambiguous: Algorithms must be clear and precise, with each step defined in an
unambiguous way so that they can be followed exactly and produce the same result every time
they are executed.
- Well-defined inputs and outputs: Algorithms must have well-defined inputs and outputs, so
that the results can be easily verified and compared to the expected outcome.
- Finite and terminating: Algorithms must be finite and terminating, meaning they must
eventually come to an end and produce a result. They should not run indefinitely or produce an
infinite loop.
- Deterministic: Algorithms must be deterministic, meaning that they will produce the same
output given the same inputs, every time they are executed.
- Efficient: Algorithms should be designed to use resources (such as memory, processing time, or
energy) as efficiently as possible.
- Generalizable: Algorithms should be generalizable, meaning that they can be applied to a wide
range of problems or data sets, rather than being specific to a single problem or data set.
- Correctness: Algorithms must produce the correct output for all possible input values, meeting
the specified requirements of the problem they are designed to solve.
Overall, algorithms are systematic and precise procedures for solving problems or achieving specific
objectives. These characteristics ensure that algorithms are effective, reliable, and efficient tools for a
wide range of applications.
EXAMPLES OF ALGORITHM
- Sorting algorithms: Sorting algorithms are used to arrange a collection of data in a particular
order. Examples include bubble sort, selection sort, insertion sort, and quicksort.
- Search algorithms: Search algorithms are used to find specific items in a collection of data.
Examples include linear search, binary search, and hash tables.
- Pathfinding algorithms: Pathfinding algorithms are used to find the shortest path between two
points in a graph or network. Examples include Dijkstra's algorithm, A* search, and breadth-first
search.
- Encryption algorithms: Encryption algorithms are used to convert plaintext into ciphertext to
protect sensitive information. Examples include Advanced Encryption Standard (AES), RSA, and
Elliptic Curve Cryptography (ECC).
- Compression algorithms: Compression algorithms are used to reduce the size of data to save
storage space or transmission bandwidth. Examples include LZ77, Huffman coding, and
Arithmetic coding.
- Machine learning algorithms: Machine learning algorithms are used to build models that can
make predictions or decisions based on data. Examples include linear regression, logistic
regression, k-nearest neighbors, decision trees, and neural networks.
- Image processing algorithms: Image processing algorithms are used to manipulate or analyze
digital images. Examples include edge detection, image segmentation, and feature extraction.
- Rinse the rice thoroughly in a fine-mesh strainer under cold running water. Use your fingers to
gently rub the grains to remove any excess starch or debris.
- In a medium-sized pot, add the rinsed rice and the appropriate amount of water. The general
rule of thumb is to use a 1:2 ratio of rice to water, but check the specific instructions on the
package.
- Bring the pot of rice and water to a boil over high heat.
- Once the water is boiling, reduce the heat to low and cover the pot with a tight-fitting lid.
- Simmer the rice for about 18-20 minutes, or until all the water has been absorbed and the rice is
tender.
- Turn off the heat and let the rice sit covered for an additional 5 minutes to allow the steam to
continue cooking the rice and make it fluffier.
- After the 5 minutes have passed, use a fork to fluff the rice and release any clumps.
- Serve the rice hot and enjoy!
Note: The cooking time and water ratio may vary depending on the type of rice being used, so always
check the specific instructions on the package.
1. Read and understand the problem statement. Make sure you know what you are being asked to
solve and what information is given.
2. Identify what you are trying to solve for. This may involve identifying unknown variables or
parameters.
3. Determine any relevant equations or formulas that may be used to solve the problem. Make
sure you understand how to use these equations and any units or constants involved.
4. Plug in the given values and solve for the unknown variable or parameter. Make sure to keep
track of units and follow the rules of algebra.
5. Check your answer to make sure it is reasonable and makes sense in the context of the problem.
Does your answer match the units given in the problem? Does it make sense based on the
problem statement?
6. If necessary, re-read the problem statement and your solution to make sure everything is
correct.
7. If you are satisfied with your answer, write it down and move on to the next problem. If you are
not satisfied with your answer, go back and check your work or seek help from a teacher or
tutor.
Note: This is a general algorithm that can be applied to many mathematical problems. The specific steps
may vary depending on the type of problem and the mathematical concepts involved.