Chapter I Basic Elements
Chapter I Basic Elements
Faculty of Sciences
Department of Computer Science
Computer Science Engineering
Semester 1 (1st year)
2024-2025
Available at https://sites.google.com/a/esi.dz/informatiqueblida/algorithmique-et-structure-
de-donn%C3%A9es
PREAMBLE
Weekly Hourly Volume
[According to the annex of decree No. 060 of January 15, 2023, which sets the curriculum for the common core program
leading to the State Engineer diploma in the field of "Mathematics and Computer Science"; major: "Computer Science."]
PREAMBLE
Evaluation: Continuous Control + Final exam.
Module Resources: The course materials (slides pdf), tutorial and lab series,
test/exam topics, and their corrections will be available on the Google site:
https://sites.google.com/a/esi.dz/informatiqueblida/algorithmique-et-structure-
de-donn%C3%A9es
3
Regularly check the latest versions under the tab « Année Universitaire 2024-2025 »
PREREQUISITES
What do I need to master algorithmic? (Required skills)?
A minimum of general culture, as the problems to solve come from various fields.
Understanding the language used in the problem statement (French and/or English).
Regularly and continuously review the module (at least once a week).
Be able to:
Proceed with the modular decomposition of the software.
Analyze and separately build the different modules (main and secondary).
Validate each module.
Separately program the various algorithms corresponding to the modules.
5
Make a technical programming dossier.
CONTENT
I. BASIC ELEMENTS
V. PERSONLISED TYPES
6
Saad Dahlab University - Blida1
Faculty of Sciences
Department of Computer Science
Computer Science Engineering
Semester 1 (1st year)
2024-2025
Available at https://sites.google.com/a/esi.dz/informatiqueblida/algorithmique-et-structure-
de-donn%C3%A9es
CONTENT
etc.
8
BASIC CONCEPTS
Definitions 1:
9
BASIC CONCEPTS
10
BASIC CONCEPTS
11
BASIC CONCEPTS
12
BASIC CONCEPTS
Definitions 1:
data result
data result
Data (Ingredients)
Preparation Methods
(Actions: steps from 1 to
4)
Result (Usable 16
Paste)
BASIC CONCEPTS
Example 2: Guiding a Visitor
Suppose a visitor comes to you and asks for Data
Destination (Bank) +
directions to the bank.
Starting Position +
Since you know its exact location, you might say, City Map
for example:
1. Go straight.
2. At the second intersection, turn left. Description of the route
3. Go straight. (Actions: steps from 1 to
5)
4. At the first intersection, turn right.
5. After 50 meters, you’ll find the bank on your right.
Result: Final 17
position (in front of
the bank)
BASIC CONCEPTS
Example 3: Calculate a student's average for a set of modules.
Module M1 M2 Mn
Value X1 X2 …… Xn
Coefficient C1 C2 ……. Cn
∗ !"
=
"#
∗ ∗ …. ∗ ∑ ∗
= = ∑
18
…..
BASIC CONCEPTS
Example 3: Calculate a student's average for a
set of modules.
So, we must :
1. Define the number of modules involved (denoted
Data (n, Mi, Xi, Ci)
as n) as well as the score (Xi) and the coefficient
(Ci) of each module (Mi).
2. Perform the following operations: Calculation operations
a. Multiply each module’s score by its coefficient. (Actions: step 2 (a c))
b. Calculate the sum of the multiplication results.
c. Divide the sum by the total coefficients.
Result
3. Display the student's average (final result). The average
19
displayed
BASIC CONCEPTS
Example 4: Solving a quadratic equation (second degree)
20
BASIC CONCEPTS
Example 4: Solving a quadratic equation (second degree)
Input Data
Actions:
1. Calculate ∆
2. Depending on ∆, display
the solution(s) if it exists.
21
Results: Display messages and solutions.
BASIC CONCEPTS
Definition 3: An algorithm is a sequence of primitive actions that, when
correctly executed by a processor, will yield the desired result.
criteria:
Correctness: It must yield the correct result (correct logic).
Exactness: It must account for all possible cases, handling both the
general and specific cases.
Finiteness: It must terminate after a finite number of actions.
Precision: It should clearly specify the inputs (data entry) and outputs
(result display).
Efficiency: It should return results within an acceptable time, regardless
of the size of the input data.
Independence: It should be independent of programming languages and23
computer hardware.
BASIC CONCEPTS
To solve a given problem, two phases are necessary:
1. Algorithmic phase: Converts a problem to be solved into an algorithm
that describes the problem-solving process.
Definition 4: Algorithmic is the science of algorithms, focusing on the art of
constructing algorithms and determining their validity, robustness, reusability,
complexity, and efficiency.
2. Programming phase: Translates an algorithm into a language
"understandable" by the computer for automatic execution.
Machine 0010110110010011010011110
Calculate 4 + 7 Natural Language
Language
Machine Language
Binary Low-Level Language
Assembly Hight-Level Langage
More complex and closer to the
machine’s operation More simple and farther
from the machine's operation
C, C++, Objective-C, …
Python, Java, C#, Ruby, ..
27
PROGRAMMATION
Programming Languages:
A programming language is a set of rules and conventions used to write
instructions that will be executed by a computer. It is a means of
communication between programmers and machines, and allows developers
to create software, applications, websites, and other types of programs.
Low-level program
1 second 1 year
Hight-level program
28
5 seconds 1 month
PROGRAMMATION
The most used programming languages in 2024
29
PROBLEM SOLVING STEPS
Solving steps
Design
Error
Precise step-by-step
Problem ANALYSIS ALGORITHM
Statement Process
Logic Syntax
Error
30
RESULTS DEBUGGING PROGRAM
Implementation
PROBLEM SOLVING
The analysis MUST be carried out BEFORE the algorithm is built. This
involves :
giving the basic idea(s),
formulating them in simple, concise, clear sentences or with a diagram
And then structuring them.
Don't hesitate to use your own conventions (drawings, diagrams, narrations, colours, ....).
Objects Object 1 ……
Actions
1
2
……
32
PROBLEM SOLVING
Example 5 (solution 1):
Problem: Find the divisors of a number.
Precise Statement: Given a non-zero natural number N, give (or construct)
the algorithm that provides a list of its divisors.
Analysis :
Let N be a non-zero natural number.
Divide N successively by i = 1, 2, 3 ,..., N.
Whenever the remainder of the division of N by i is 0 (i.e., i is a divisor),
Print i
33
PROBLEM SOLVING
Example 5 (solution 1):
Problem: Find the divisors of a number.
Precise Statement: Given a non-zero natural number N, give (or construct)
the algorithm that provides a list of its divisors.
Analysis 1 (more detailed):
Let N be a non-zero natural number.
Generate divisors i from 1 to N:
To generate the divisors i, add 1 each time to i, which is 1 at the start.
For each divisor generated:
divide N by i.
Keep the remainder of the division. 34
36
PROBLEM SOLVING
Example 5: Step-by-step Process (N = 21):
N i Remainder N/i Print (i) N i Remainder N/i Print (i)
21 12 9
1 0 1 13 8
2 1 14 7
3 0 3 15 6
4 1 16 5
5 1 17 4
6 3 18 3
7 0 7 19 2
8 5 20 1
9 3 21 0 21
10 1 37
11 10
PROBLEM SOLVING
Example 5:
Result of 38
execution (in
console)
COURSE SOURCES
39