0% found this document useful (0 votes)
11 views

Chapter I Basic Elements

The document outlines the syllabus for the 'Algorithmic and Data Structures 1' course at Saad Dahlab University for the 2024-2025 academic year, detailing prerequisites, evaluation methods, and course objectives. It emphasizes the importance of mastering algorithmic concepts, programming languages, and problem-solving techniques. Key topics include basic elements of computer science, algorithm formalism, and practical applications using C language.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Chapter I Basic Elements

The document outlines the syllabus for the 'Algorithmic and Data Structures 1' course at Saad Dahlab University for the 2024-2025 academic year, detailing prerequisites, evaluation methods, and course objectives. It emphasizes the importance of mastering algorithmic concepts, programming languages, and problem-solving techniques. Key topics include basic elements of computer science, algorithm formalism, and practical applications using C language.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 39

Saad Dahlab University - Blida1

Faculty of Sciences
Department of Computer Science
Computer Science Engineering
Semester 1 (1st year)

ALGORITHMIC AND DATA


STRUCTURES 1

Mrs AROUSSI ([email protected])

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.

Continuous Control (CC) = (Tutorial Score + Practical Work Score) / 2

Tuto Score: 2 tests (15 pts), preparation, attendance, homework

PW Score: Lab test (15 pts), project, preparation, attendance, homework

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).

Mastery of some mathematical concepts.

Be rigorous, have good logic, and a lot of patience and courage.

What should I do to master algorithmic?


Love the module to find your own solution to the given problem.

Regularly and continuously review the module (at least once a week).

Learn the method of solving rather than the solution itself. 4

Do a lot of exercises to improve reflexes.


OBJECTIVES
Acquisition of a methodological approach focused on modularity that
allows the design and realization of a small software using elementary
objects and static data structures (one-dimensional and two-dimensional
arrays, strings, sets, records).

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

II. PRESENTATION OF ALGORITHMIC FORMALISM

III. BASIC ELEMENTS OF C LANGUAGE

IV. ARRAYS & STRING

V. PERSONLISED TYPES

6
Saad Dahlab University - Blida1
Faculty of Sciences
Department of Computer Science
Computer Science Engineering
Semester 1 (1st year)

CHAPTER I: BASIC ELEMENTS

Mrs AROUSSI ([email protected])

2024-2025

Available at https://sites.google.com/a/esi.dz/informatiqueblida/algorithmique-et-structure-
de-donn%C3%A9es
CONTENT

Basic Concepts: Computer Science, Algorithm, Action, Processor, Computer,

etc.

Programming: Programs and Programming Languages

Problem Solving (Analysis and step-by-step Process)

8
BASIC CONCEPTS
Definitions 1:

Computer science is the study of computers and computational systems. It


encompasses the theory, design, development, and application of the
software and hardware components that make up these systems.

9
BASIC CONCEPTS

10
BASIC CONCEPTS

11
BASIC CONCEPTS

12
BASIC CONCEPTS
Definitions 1:

Computer science is the study of computers and computational systems. It


encompasses the theory, design, development, and application of the
software and hardware components that make up these systems.

Computer science is the study of computation, information, and


automation. It spans theoretical disciplines (such as algorithms, theory of
computation, and information theory) to applied disciplines (including the
design and implementation of hardware and software).
L’informatique est la science du traitement automatique de l’information [Fr]. 13
BASIC CONCEPTS
Automatic information processing involves executing instructions
(elementary and complex operations) on input data to generate other
information called results or output data. This processing corresponds to an
algorithm.

data result

Definition 2: An algorithm is an ordered sequence of instructions or


actions that outlines the procedure to solve a problem or perform a task.
The term algorithm comes from the Latinized name
of the Persian mathematician Al-Khawarizmi, known as 14

"the father of algebra".


BASIC CONCEPTS
Definition 2: An algorithm is an ordered sequence of instructions or
actions that outlines the procedure to solve a problem or perform a task.

data result

When writing an algorithm, the following questions should be considered:


What is the expected result?
What data is required (necessary information)?
How to proceed (the treatment to be performed)? 15
BASIC CONCEPTS
Example 1: A Recipe (Flour Paste)

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.

A processor can be any entity capable of understanding and executing


the actions constituting an algorithm. It can be a person, an electronic
device (alarm), a mechanical device (vending machine), or a computer.

The set of objects (elements) necessary to carry out a task described by an


algorithm is called the environment.

An action is a step in an algorithm. It is a finite-duration event that


modifies the environment. 22

A primitive action is an action that a processor can execute without any


BASIC CONCEPTS
PROPERTIES: For an algorithm to be valid, it must meet the following

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.

Problem Algorithm Program


Algorithmic Programming 24
BASIC CONCEPTS
Definition 5: A computer is a machine capable of automatically performing
arithmetic and logical operations based on programs that define the sequence
of these operations.
A computer understands only machine language (also called binary language).
How to
communicate? Hence the need for communication tools
that best adapt to users

Machine 0010110110010011010011110
Calculate 4 + 7 Natural Language
Language

Programming languages allow the translation of algorithmic language into25 a


binary program for the computer.
PROGRAMMATION
Definitions 6:
An Algorithmic language is a set of rules for correctly writing an
algorithm.
Programming is the translation of the algorithm into a programming
language.
A Program is a sequence of instructions written in a programming
language that translates an algorithm. Each instruction specifies the
operation the computer must perform.

Problem Algorithm Program


Algorithmic Programming 26
« Natural « Algorithmic «Programming
Language » Language » Language»
Definitions 6:
PROGRAMMING
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. es
applications, des sites web et d’autres types de programmes.

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, ....).

Important tip: use a well-chosen example to explain your idea.


Validate the analysis by asking :
1. Is the basic idea correctly and simply expressed?
2. Are the derived ideas well-structured?
3. Have I avoided unnecessary details that might confuse the analysis?
31
PROBLEM SOLVING
The step by step process consists of running the algorithm, action by action,
by hand, to check that it gives the desired result.

It can be summarised in a table in which each column represents an object


in the environment and each row an action in the algorithm.

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

If it is 0, then i is a divisor and must be printed.


PROBLEM SOLVING
Example 5 (solution 2):
Knowing that the number 1 is a divisor of any number and that a number N
is a divisor of itself [special cases], we can vary the loop i from 2 to N/2 to
find the other divisors [general case].
Let N be a non-zero natural number.
Print (1)
Generate divisors i from 2 to (N div 2)
For each divisor generated
Divide N by i.
Keep the remainder of the division
If it is equal to 0, then i is a divisor and must be printed.
35
Print (N)
PROBLEM SOLVING
Example 5:
Analysis 1:
Let N be a non-zero natural number. Algorithm Diviseurs
Generate divisors i from 1 to N. Var
N, i : Integer
For each divisor generated: Begin
divide N by i. scan (N)
If the remainder of the division is 0, For i  1 to N do
then i is a divisor and must be If ((N mod i ) = 0) then print (i)
printed. End.

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:

Algorithm Diviseurs C Program


Var
N, i : Integer
Begin
scan (N)
For i  1 to N do
If ((N mod i ) = 0) then print (i)
End.

Result of 38
execution (in
console)
COURSE SOURCES

B. CHERGOU (2014) & N. MEDJAOUI (2018), Cours d’algorithmique/pascal, 1st-year CPI,


Higher National School of Computer Science (ESI) Oued Smar, Algiers.

M. ZAIR (2022), Algorithmique 1, 1st-year License Common Core MI (Mathematics and


Computer Science), Faculty of Sciences, Saad Dahlab University, Blida.

O. Hadj Yahia (2022), Bureautique, algorithmique et langage de programmation, 1st-year


License Common Core SM, Faculty of Sciences, Saad Dahlab University, Blida.

39

You might also like