0% found this document useful (0 votes)
11 views36 pages

01 - Introduction en

The document discusses algorithms and data structures, defining algorithms as sequences of instructions that transform input values into output values. It emphasizes the importance of clearly formulating problems and the need for algorithms to be correct, efficient, and precise. Additionally, it highlights the relationship between algorithms and data structures in solving complex problems, particularly in programming and computer science.

Uploaded by

Jamil Dk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views36 pages

01 - Introduction en

The document discusses algorithms and data structures, defining algorithms as sequences of instructions that transform input values into output values. It emphasizes the importance of clearly formulating problems and the need for algorithms to be correct, efficient, and precise. Additionally, it highlights the relationship between algorithms and data structures in solving complex problems, particularly in programming and computer science.

Uploaded by

Jamil Dk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 36

ALGORITHMIC

AND
DATA STRUCTURE
Dr. R. TLEMSANI
For what?
Computing involves computers that operate
according to pre-established patterns .
To solve a given problem using a computer, it must
be told the sequence of actions to be carried out in its
operating diagram .
This sequence of actions is a program which is
expressed in a more or less evolved programming
language (machine code, C, C++, Java , Caml ,
Prolog, . . .).
To write a program (the sequence of actions), you
must first know how to solve the problem.
ALGORITHMIC
ALGORITHMIC
An algorithmic problem is often formulated as the
transformation of a set of input values into a new set
of output values.

Examples of algorithms:
A cooking recipe
Searching in a dictionary
The integer division
Sorting a sequence
ALGORITHMIC
An algorithm is the expression of the resolution of a
problem so that the result is computable by a
machine.
The algorithm is expressed in a theoretical model of a
universal machine (Von Neumann) which does not
depend on the real machine on which it will be used.
It can be written in natural language, but to be
readable by all, a more restricted algorithmic
language is used which includes all the basic concepts
of machine operation .
DEFINITION
An algorithm is a sequenceALGORITHM:
of instructions , which when executed
correctly, leads to a given result .
An algorithm must therefore contain only instructions that can be
understood by the person who will have to execute it.

GOALS
It describes the steps to follow to complete a job.
It makes it possible to clearly formulate the solution ideas of a
problem independently of a programming language .

ORIGIN OF THE WORD:


Masculine name (of Al-Khârezmi, Muslim scientist).
ALGORITHMIC
We finally have the following sequence:

Statemen Program
Algorithm
t of the (universal)
(linked to a
problem machine)
CONCEPT
INDICATE THE PATH TO
A PERSON

1
• Take the 1st
street on the left,
• Continue straight
until the 1st
crossing
• turn right _
CONCEPT
Mean general of a
student from 4 notes

2
• Sum the four Rating1 + Rating 2 + Rating
notes
• Divide the sum 3 + Rating 4 = S

by 4
If the result is
S/4=M
greater than 10 M >= 10: allowed
is admitted
• Otherwise inform M < 10: postponed
that the student
is adjourned
Problem and statement
A problem has a statement that gives information
about the expected result .
The statement can be in natural language, imprecise,
incomplete, and generally does not give the way to
obtain the result.
Examples:
calculate the GCD of two numbers;
calculate the area of a room;
arrange a list of words in alphabetical order;
calculate x such that x divides a and b and if there exists y
which divides a and b then x ≥ y.
The last example describes the result very precisely
but does not tell us how to calculate it.
Problems solving
To solve a problem, it is necessary to give the
sequence of elementary actions to be carried out to
obtain the result.
The elementary actions available are defined by the
algorithmic language used.
Example: “Building a house”
Level the ground
SO
Lay the foundations Lay the roof
Climb the walls Lay
• The the
order frame is
of operations
Lay the roof Lay thebutrafters
important, in some cases
install electricity several
Lay the ordersbattens
are possible.
Install the pipes • Sometimes you have to break
Lay actions
down the underlay
that are too
Add doors and windows
Lay the cover
complex.
An example
algorithm for calculating the GCD of two
integers .
Data: two integers a and b
Result: GCD of a and b
1. Order the two numbers such that a ≥b .
2. Calculate their difference c  a - b .
3. Repeat by replacing a by c ( a  c) until a becomes
equal to b.
4. The result is then a (= b)
Languages
States Algorithm Program

Programming
Algorithmic
natural language language
language
Languages
A language is made up of two elements:
the grammar which fixes the syntax;
the semantics that gives meaning.
The language therefore answers two
questions:
how to write things
what do the written things mean?
Algorithms
We will mainly study the correct algorithms.
An algorithm is (completely) correct when for each
instance it terminates producing the correct output.
There are also partially correct algorithms whose
termination is not assured but which provide the correct
output when they terminate.
There are also approximate algorithms which provide an
inaccurate but nevertheless close to optimum output.
Algorithms will be evaluated in terms of resource
usage , mainly in relation to computation times but
also to usage . of memory .
Algorithms
An algorithm can be specified in different
ways :
in natural language,
graphically,
in pseudocode,
by a program written in a computer language
...
The only requirement is that the description be
accurate .
Pseudo code
Objectives :
Describe algorithms in a way that they can be
understood by humans .
Make the description
Get rid of details such as error handling, type
declarations , etc.
Very close to C ( procedural language rather
than oriented object)
Can contain some natural language
instructions if needed
DATA STRUCTURE
DEFINITION
The way data is represented in a computer.

GOALS
Allow complex data to be represented in a clear, easy , and organized
manner, the purpose of which may be to take up less space or speed
up access to it.
DATA STRUCTURE
Method for storing and organizing data for
easy access and modification
A data structure includes:
a number of data to manage , and
a set of operations that can be applied to this data
In most cases, there is
several ways to represent the data and
different manipulation algorithms.
A distinction is generally made between the
interface of structures and their
implementation.
What is it about?
You have a problem.
You think a bit...
You analyze what to do
You find a way to solve it.. (mostly in steps)
You order your steps
You start running them
..You have just found the algorithm of your Problem.
Example:
Continuing your studies abroad…
The problem: Going abroad for studies.
I analyze what to do
I suggest to follow the following steps:
1. I apply for a visa if necessary
2. I'm starting the registration process.
3. I await the first confirmation.
4. I contact an establishment.
5. If confirmation arrived I continue the following steps
6. I arrive at the host university to complete my registration.
7. Visa obtained: I buy a plane ticket
8. …
Disorder in your sequence of actions ( … )
• Your Solution (The Algorithm)
HAS NO LOGIC

• a Best Proposal
( A better Algorithm )

Is the following:
Example:
Continuing your studies abroad…
The problem: Going abroad for studies.
I analyze what to do
I suggest to follow the following steps:
1. I contact an establishment.
2. I start the registration process.
3. I await the first confirmation.
4. If confirmation arrived I continue the following steps
5. I apply for a visa if necessary
6. Visa obtained: I buy a plane ticket
7. I arrive at the host university to complete my registration.
8. … etc( …)
ANOTHER EXAMPLE: COOKING RECIPE
Pancake batter ingredients:
200g flour
1 pinch of salt
ENTRANCE:
½ sachet of yeast
Declaration: List of ingredients
3 tablespoons oil
Initialization: Dosage of each ingredient
15cl of water
15 cl of milk
TREATMENT:
4 eggs
I1: break the eggs
4 tablespoons of rum
I2: beat the eggs
2 tablespoons sugar + vanilla
I3: add sugar + vanilla
I4: add flour + yeast + salt
Preparing the dough out of order:
I5: mix the ingredients
add sugar + vanilla
I6: mix everything with water + milk + rum + oil
if the batter is too thick, add a little milk
I7: if the batter is too thick, add a little milk
mix the ingredients
scramble the eggs
EXIT:
let the dough rest
I8: let the dough rest
break the eggs
mix everything with water + milk + rum + oil
add flour + baking powder + salt
Algorithm
We present the algorithms as a sequence of instructions in the
order of processing.
The "algorithmic language" we use is a compromise between a
natural language and a programming language .
We will handle the types commonly encountered in
programming languages: integer, real, boolean , character ,
string, array and composite type.
Properties of an algorithm
• sharpness
Precision that leaves no room for arbitrariness.
Thanks to this property, the realization of an
algorithm is a mechanical process.

• Efficiency
Is the property of leading to the desired result
after a finite number of operations.
General diagram of an algorithm
• Declaration of objects
Beginning
• Initialization of objects
• Actions part
An object is characterized
END by its:
1. Name
2. Kind
3. value

An action is an event that takes place


for a finite period of time and
produces a well-defined and planned
result,
THREE RECURRING QUESTIONS
FACING AN ALGORITHM

1. my algorithm correct, does it


terminate?
2. What is its execution speed ?
3. Is there a way to do better ?
ALGORITHMS
+
DATA STRUCTURES
=
PROGRAMS
DATA STRUCTURES AND
ALGORITHMS IN PRACTICE

Algorithmic problem solving almost always requires


the combination of data structures and sophisticated
algorithms for managing and searching those
structures.
This is especially true when dealing with large
volumes of data .
Some examples of real problems :
Routing in computer networks
Search engines
Alignment of DNA sequences in bioinformatics
ALGORITHMIC
LANGUAGE DESIGN STEPS

The design of an algorithm is the most difficult


phase.
We prefer a hierarchical methodology by
breaking down the algorithm into parts.
Each part is itself broken down until obtaining
elementary instructions (successive
refinements).
ALGORITHMIC
LANGUAGE DESIGN STEPS

The different elements of an algorithm are:


Data description what should be given to the
algorithm
Description of the results what the algorithm should
produce
Idea of the algorithm the main stages of processing and
calculations
Glossary of variables list of values handled
Algorithm details of processing and calculations
ALGORITHMIC
LANGUAGE DATA AND RESULTS

Description of data
Specify precisely what should be given to the
algorithm before using it .
Summary:
Use of the keyword “Data” followed by natural
language text describing the data.
ALGORITHMIC
LANGUAGE DATA AND RESULTS

Description of results
Specify precisely what the algorithm must produce
and the link between the result and the data
provided at the start.
Summary:
Use of the keyword “Results” followed by natural language
text describing the result.

DATA RESULTS
ALGORITHM
Questions?

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy