Computer
Algorithms
• What Is an Algorithm?
• An algorithm is a step-by-step set of
instructions or a defined process used
to solve a specific problem, perform a
task, or achieve a desired result.
• It is a fundamental concept in
computer science, mathematics, and
everyday problem-solving.
• Key Characteristics of an Algorithm:
• Well-Defined Steps: Each step must be clear and
unambiguous.
• Finite: The algorithm must complete in a finite
number of steps.
• Input: It may accept input values.
• Output: It produces at least one output or result.
• Effectiveness: The steps are basic enough to be
performed, typically by a computer or a human.
• Examples of Algorithms:
• Sorting Algorithms: Procedures to arrange
data in a specific order, like bubble sort or
quicksort.
• Search Algorithms: Techniques to find
elements in a dataset, such as binary search.
• Mathematical Algorithms: Methods to solve
mathematical problems, like finding the
greatest common divisor (GCD).
• Everyday Algorithms: Instructions for tasks
like baking a cake (recipe) or following
directions to a location.
• Algorithms and Computers: A Perfect Match
• Computers, at their core, are powerful machines capable of
performing basic operations—like addition, subtraction, and
comparisons—at remarkable speeds.
• However, they lack reasoning or creativity. Algorithms give
computers a structured set of instructions to follow, enabling them
to:
• Solve Problems: Break down complex tasks into manageable
steps.
• Process Data: Organize, analyze, and manipulate large amounts
of data.
• Make Decisions: Use logical conditions to determine actions
(e.g., if-else statements).
• Without algorithms, computers would be unable to perform any
meaningful tasks.