ASD I Course Chapter 1.2 Introduction Algorithms
ASD I Course Chapter 1.2 Introduction Algorithms
Chapter 1
Introduction :
2. Introduction to Algorithms
Noureddine AZZOUZA
1
Course
Topics
1. Algorithms
1.1 Definitions
1.2 Examples
1.3 History
2. Programming
2.1 Definitions
Goal
Getting the “machine” to do work for us.
Problem
explain to the "machine" how it should do it.
Algorithms
Objectives
solve problems “like” a machine
4
ASD I Noureddine AZZOUZA
The Concepts
Concepts covered
Basic Concepts
“basic” algorithms for elementary problems
Learning a language
Algorithmic formalism,
Algorithms
5
ASD I Noureddine AZZOUZA
Algorithms
6
Algorithm
Definition
An ALGORITHM is a sequence of instructions which, once executed
correctly, leads to a given result (desired).
Examples : Algorithms
Algorithms
7
ASD I Noureddine AZZOUZA
Algorithm
Algorithm
The actions
The processor
8
Algorithm
Definition : Processor
An algorithm is always executed by a PROCESSOR.
Definition : Environment
Environment :
We distinguish:
Definition : Action
Actions :
The same action can appear several times in the same algorithm
11
ASD I Noureddine AZZOUZA
Algorithm
Definition : Algorithm
12
ASD I Noureddine AZZOUZA
Algorithm
Properties
1. General: an algorithm must always be designed in such a way as to consider all
eventualities of a treatment (take into account all possible cases).
2. Finitude: An algorithm must stop after a finite time (finite number of primitive
actions).
Algorithms
Learn Algorithms
To master Algorithms, three (3) qualities are required :
1. be methodical:
Before writing the instructions for an algorithm, you must analyze the problem
to be solved. You must then define the inputs and outputs of Algorithm.
Algorithms
2. have intuition:
No recipe allows you to know a priori which instructions will achieve the desired
result. The reflexes of algorithmic reasoning become spontaneous with
experience.
3. Be rigorous :
Each time you write a series of instructions, you must systematically put yourself
14 mentally in the place of the ASD
machine
I
that will execute them. Noureddine AZZOUZA
Historique
History of Algorithms
1. 18th century BC AD. :
the Babylonians defined exhaustive descriptions of
algorithms for calculations concerning trade and taxes;
Algorithms
2. 3rd century BC AD :
Euclide introduced (in his work The Elements) the famous
algorithm which makes it possible to find the greatest
common divisor (PGCD) of two numbers;
15
ASD I Noureddine AZZOUZA
Historique
History of Algorithms
1. 9th century:
Al Khuwarizmi was the first to formalize the notion of
algorithm in his work Algebra and Balancing ;
Algorithms
2. 12th century:
Adelard de Bath introduced the Latin term algorismus
(with reference to the name of Al Khuwarizmi);
16
ASD I Noureddine AZZOUZA
Programming
17
The Program
Program
A program is a sequence of instructions written in a programming
language translating an algorithm
Programming
Each of its instructions specifies the operation that the computer must
execute.
ALGORITHM
Sequence of
Translation into a programming PROGRAM
language Instructions
primitive actions
18
ASD I Noureddine AZZOUZA
The Program
19
ASD I Noureddine AZZOUZA
The Program
Programming language
A programming language is a conventional
notation intended for formulating
(translating) algorithms and producing
Programming
(developing) programs
Examples :
20
ASD I Noureddine AZZOUZA
The Program
Programming language
C C#
Programming
Java Python
21
ASD I Noureddine AZZOUZA
Programming Tools
Programming Tools
1. Editor:
A text or source code editor is software intended for creating and editing text
files (program source files).
Programming
2. Compiler:
It is a program that transforms source code (written in a programming
language) into object code to create a machine-executable program.
Examples:
Programming Tools
3. IDE:
The Integrated Development Environment (IDE) brings together a set of tools
specific to program development. It can contain :
Programming
A text editor
A compiler
A debugger
A GUI creator ....etc
Examples:
C/C++ Langage: DevC++, Code::Blocks, Visual Studio Code, Eclipse + CDT ...
Pascal Langage: Lazarus, Free Pascal ...
Python : PyCharm, Spyder, Visual Studio Code, Jupyter Notebook ...
23
ASD I Noureddine AZZOUZA
Programming Tools
Programming Tools
DevC++ Visual Studio Code
Programming
Eclipse Lazarus
24
ASD I Noureddine AZZOUZA
From Problem
to Solution
25
From problem to solution
Solving a problem in
From problem to solution
computer science
26
ASD I Noureddine AZZOUZA
From problem to solution From problem to solution
27
ASD I Noureddine AZZOUZA
From problem to solution From problem to solution
28
2. What is the solution to this problem? What is the form of result?
ASD I Noureddine AZZOUZA
From problem to solution From problem to solution
3. Run the Algorithm and check its operation (general case, special cases)
30
ASD I Noureddine AZZOUZA
From problem to solution From problem to solution
2. The machine translates and executes the meaning expressed by the program
development of a program
YES
completed
Expected
No results
results??
Syntactic Errors
NO Unexpected results
Logical Errors
Partial results
31
ASD I Noureddine AZZOUZA
From problem to solution From problem to solution
32
From problem to solution From problem to solution
begin
//les entrées
read (N);
34
Ministry of Higher Education and Scientific Research
Djilali BOUNAAMA University - Khemis Miliana(UDBKM)
Faculty of Science and Technology
Department of Mathematics and Computer Science
Chapter 1
Introduction :
2. Introduction to Algorithms
Noureddine AZZOUZA
35