epicours/Algo/B1/Séminaire/Introduction.md

69 lines
1.5 KiB
Markdown

<center><img src="https://i.imgur.com/8xTIMVy.png " width=auto height=400 /> </center>
## An algorithm is
- a set of rules (finite)
- sequence (finite)
- The goal is to take an input and give an output with the solution
## How to write an algorithm
1) What do you have available ; What is the output that your searching for => this is call specifications
2) How : find resolution methods and choose the best one
3) Formalism : shape it like a computer talk
4) Translate :
## Compilation and interpretation
### Compiler
```mermaid
flowchart TD
A[High Level source code] -->|Compiler| B[Machine code]
B --> C[execution]
B --> D[execution 2]
B --> E[execution ...]
```
The compiler depends on
- Language of the source code
- The computer it will run the code
Advantages :
- 1 translation
- Optimises the code
> C or C++ language use the compiler
### Interpretation
The interpretor is a live compiler that translate in realtime.
Disavantages:
- Don't optimize the code
Avantages:
- We can share only the original source code
> Javascript use interpretation
## Language families
There is two families in the language word, the imperative and the declarative
### Imperative
- State (of the memory)
- Instruction that will modify the state of the memory
- and again...
- output
### Declarative
- Defines relations between the input and the output
In the declarative languages we have
- The functional languages
- $f:x -> x+1$
- The logical languages
$$x\in{N}$$
$$x>1$$
$$x<3$$
$$\text{-> } x=2$$