algo1
algo1
Chapter 1 : Introduction
1. Computer Science
1
Badji Mokhtar Annaba university – Computer Science Department
Bachelor Of Computer Science - First Year - S1 - 2024 / 2025
Algorithms and Data Structures 1
6. Databases: Databases are essential for storing and retrieving vast amounts of structured
data, driving applications like e-commerce, social media, and healthcare.
2. Algorithms
2.1.The genesis of algorithms
Early civilizations like the Egyptians and Babylonians developed numerical systems and simple
algorithms for arithmetic calculations. The Greeks, notably Euclid, laid the groundwork for
algorithmic thinking in geometry.
The first person to systematically develop algorithms was the Persian mathematician Al-
Khwârizmî ( ,)محمد بن موسى الخوارزميactive between 813 and 833. In his work titled 'The
2
Badji Mokhtar Annaba university – Computer Science Department
Bachelor Of Computer Science - First Year - S1 - 2024 / 2025
Algorithms and Data Structures 1
Compendious Book on Calculation by Completion and Balancing' , he studied all second-
degree equations and provided their solutions through general algorithms.
As we transition to the Renaissance period, we encounter luminaries like Leonardo da Vinci,
who employed algorithmic methods in art and engineering. However, it was not until the 17th
century that calculators and mechanical devices, such as Pascal's Pascaline and Leibniz's
stepped reckoner, brought algorithms into practical use.
The 19th century witnessed the advent of Charles Babbage's Analytical Engine, often
considered the precursor to modern computers. Ada Lovelace, the world's first computer
programmer, collaborated with Babbage and wrote algorithms for the engine. His work
foreshadowed the role of algorithms in future computing.
2.2. Algorithms
An algorithm for a particular task can be defined as “a finite sequence of instructions, each of
which has a clear meaning and can be performed with a finite amount of effort in a finite
length of time”. As such, an algorithm must be precise enough to be understood by human
beings. However, in order to be executed by a computer, we will generally need a program
that is written in a rigorous formal language; and since computers are quite inflexible
compared to the human mind, programs usually need to contain more details than algorithms.
Algorithms are systematic sets of instructions used to solve specific problems. They serve as
the intellectual building blocks of computer science, enabling computers to perform tasks
ranging from sorting data to playing chess.
2.3. Algorithmic Paradigms
Divide and Conquer: One of the fundamental algorithmic paradigms, divide and conquer,
breaks down complex problems into simpler subproblems, solving each recursively. Examples
include merge sort and quicksort.
Dynamic Programming: Dynamic programming involves breaking down a problem into
smaller overlapping subproblems and solving each only once, storing the results for future
reference. Classic examples are the Fibonacci sequence and the Knapsack problem.
Greedy Algorithms: Greedy algorithms make locally optimal choices at each step, aiming to
find a globally optimal solution. Huffman coding and Dijkstra's algorithm are well-known
instances of this approach.
3
Badji Mokhtar Annaba university – Computer Science Department
Bachelor Of Computer Science - First Year - S1 - 2024 / 2025
Algorithms and Data Structures 1
The Future of Algorithms
Quantum Computing: The future holds exciting prospects with the emergence of quantum
computing. Quantum algorithms promise to revolutionize fields like cryptography,
optimization, and materials science.
Ethical Considerations: As algorithms become increasingly integrated into our lives, ethical
questions arise concerning their use in surveillance, decision-making, and bias.
4
Badji Mokhtar Annaba university – Computer Science Department
Bachelor Of Computer Science - First Year - S1 - 2024 / 2025
Algorithms and Data Structures 1
- Reusability : Once translated into code, algorithms can be reused across different
applications, enhancing efficiency and consistency.
Strategies for Algorithm Translation- Pseudocode : Start by writing pseudocode, which is a
human-readable, high-level description of the algorithm's steps without worrying about
specific programming syntax.
- Choose a Programming Language : Select a programming language that suits the
problem's requirements and your familiarity. Common choices include Python, Java, C++,
and more.
- Step-by-Step Translation : Break down the algorithm into individual steps and translate
each step into the chosen programming language incrementally.
Techniques for Algorithm Translation
- Variable and Data Structure Selection : Choose appropriate variables and data structures
to represent and manipulate data within the algorithm. Ensure they align with the problem’s
requirements.
- Conditional Statements : Use conditional statements (if-else) to handle decision-making
within the algorithm.
- Loops : Implement loops (for, while) to handle repetitive tasks or iterations.
- Functions and Modularization : Divide the code into functions or modules to promote
code reusability and maintainability.