CHAPTER01 Basic Elements
CHAPTER01 Basic Elements
INFORMATION AUTOMATIC
Algorithmics and Static Data Structures Data : text, image, audio, number , … The art of automatically triggering actions.
History
Processing refers to the set of operations performed on data
} Derived from the name of the mathematician Muhammad ibn
(information), such as sorting, calculations, text editing, etc. Musa al-Khwarizmi, the pioneer of algebra, who formalized the
concept of the algorithm in the 9th century.
3 4
Chapter I: Basic Elements Chapter I: Basic Elements
Introduction Introduction
Example of algorithms Example of algorithms Let two numbers
A and B
The calculation of the sum of two numbers A and B and displaying the
result : } The most famous algorithm is
Divide Replace
Euclid's algorithm, which calculates A by B B byC
Guess the operations of the algorithm solving this problem! the Greatest Common Divisor Put the Replace
rest in C A by B
(GCD) of two numbers whose
YES
factorization is unknown C≠0?
1. Enter the first number (A)
NO
2. Enter the second number (B)
Display
3. Add A+B and store the result in C } See the flowchart
B
4. Display C
End
5 6
BEGIN
<Operations>
END 9 10
11 12
Chapter I: Basic Elements Chapter I: Basic Elements
Introduction Introduction
The concept of a program Steps in problem-solving
} The first usable language for programming a computer is assembly The automatic resolution of a problem is carried out in several steps :
language.
1) Problem Definition,
} Depends on the machine's processor.
2) Problem analysis,
} Its instructions are close to those of machine language.
3) Writing the algorithm,
} Allows for the creation of relatively simple programs
4) Simulating an execution of the algorithm,
} To create more complex and less machine-dependent programs, it is 5) Programming,
necessary to use a programming language. For example : C, 6) Solution validation.
C++, C#, Java, Python, Pascal, Lisp, Prolog, Fortran, Cobol, ...
13 14
15 16
Chapter I: Basic Elements Chapter I: Basic Elements
Introduction Introduction
Steps in problem-solving Steps in problem-solving
Step 3: Writing the algorithm Step 4 : Simulating an execution of the algorithm
After analyzing the problem, we move on to writing the algorithm The execution simulation involves running the algorithm step by step
respecting the algorithmic formalism. This mainly includes these three manually to check that it produces the expected result.
parts:
17 18
19 20
Chapter I: Basic Elements Chapter I: Basic Elements
Introduction Introduction
Steps in problem-solving Steps in problem-solving: Example
Step 1: Problem Definition
Validated
Problem Results
Erreurs
Errors
Syntax Logic
21 22
23 24
Chapter I: Basic Elements Chapter I: Basic Elements
Introduction Introduction
Steps in problem-solving: Example Steps in problem-solving: Example
Step 4 : Simulating an execution of the algorithm Step 5 : Programming
The translation of the algorithm to a C program.
Operations a b C Delta X #include <studio.h>
#include <stdlib.h>
int main()
{
[Declaration of input and output data]
[Instructions]
[Results display]
The algorithm is validated if the results obtained are correct. return 0;
}
25 26
Problem:
} Test the program for the 3 cases of delta (null, positive, and Find the list of divisors of a number.
negative) using different values for a, b, and c.
27 28
Chapter I: Basic Elements Chapter I: Basic Elements
Introduction Introduction
Steps in problem-solving: Exercise Steps in problem-solving: Exercise
Problem analysis:
Problem definition:
— Let be an integer N
Given an integer N, find the solution to display the list of divisors of — Successively divide N by i = 1, 2, 3 ,..., N / 2
the integer N.
— Check the remainder of the division of N by i each time
— If the remainder is equal to 0, then i is a divisor
— Display i
29 30
31 32
Chapter I: Basic Elements Chapter I: Basic Elements
Introduction Introduction
Steps in problem-solving: Exercise Steps in problem-solving: Exercise
15
1
3
5
…
33 34