0% found this document useful (0 votes)
41 views24 pages

Introduction To Algorithmics

The document outlines the Algorithmics course for first-year engineering students at the University of Science and Technology Houari Boumediene, detailing the curriculum for two semesters. It covers fundamental concepts in computer science, problem-solving steps, and the importance of algorithms and programming languages. The course aims to teach students how to analyze problems and implement solutions using the C programming language.

Uploaded by

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

Introduction To Algorithmics

The document outlines the Algorithmics course for first-year engineering students at the University of Science and Technology Houari Boumediene, detailing the curriculum for two semesters. It covers fundamental concepts in computer science, problem-solving steps, and the importance of algorithms and programming languages. The course aims to teach students how to analyze problems and implement solutions using the C programming language.

Uploaded by

zsam20710
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

People's Democratic Republic of AlgeriaUniversity of Science and

Technology Houari Boumediene


Faculty of Electronics and Computer Science

Algorithmics Course for 1st Year Engineering in Computer Science


Presented by: Mrs. Medjadba(: [Link]@[Link])
• Course: Algorithmics
• Professor : MEDJADBA
• Address mail: [Link]@[Link]
• Office 224 Computer Science Faculty.

2
Annual Module Program
Semester 1
• Chapter 1: Introduction to Computer Science
• Chapter 2: Steps for Solving a Problem in Computer Science
• Chapter 3: The Algorithmic Language
• Chapter 4: Arrays
• Chapter 5: Parameterized Actions

Semester 2
• Chapter 6: Records
• Chapter 7: Sequential Files
• Chapter 8: Pointers
• Chapter 9: Simple Linked Lists 3
Definition from – wikipedia -

Computer science consists of the automatic processing of


digital information by executing computer programs on
machines.

Processing

Digital
Machines
Informations
Programmes

But how to do all this?


4
For millennia, humans have created and used tools to help
them perform difficult tasks.

5
To create a tool that helps us perform a task, we need to understand
well what we need to do. In the end, this tool will replace us in
performing the task.
What happens in information processing?
As human beings, to process information:

Have Process Give


information information results

6
So the tool that will replace us must do the same thing!
But in an Automatic way

Have Process Give


information information results

Input Unit Central Processing Unit Output Unit


7
So the tool that will replace us must do the same thing!
But in an Automatic way

Have Process Give


information information results

Central Processing Unit Output


Input Unit
(CPU) Unit
(IU)
(OU)

computer system
8
Yes, but how to transfer the information?

Good question, we know that every living being has its own
communication language: humas, bees, ants, ...
OK, but our famous machine is not a living being!!!!
That's true, but we can always give it life. For a deaf person, we
always find a way to transmit information, right? We use sign
language!

So here too, we will use a sign language! Well, more precisely


an electrical signal,
We use zeros (0) and ones (1), which we call BIT (BInary digiT).
But how does the machine manage to perform operations?

The machine is like a child, we teach it basic things, then


when we ask it to repeat, it repeats. The machine is equipped
with a set of basic circuits that perform simple operations.

To perform a given processing, it's up to us to adapt: we


must find solutions using the same language as the machine!

But what language does the MACHINE speak?!

Je ne
comprends
rien

10
Machine Language
Machine language, or machine code, is the sequence of bits
that is interpreted by the processor (processing unit) of a
computer executing a computer program. It is the only
language that the processor can process. It is composed of
instructions and data to be processed encoded in binary.
(Wikipedia)

The machine only understands 0s and 1s. It's not that simple
to talk to it!?...
That's true, it's not that simple!? But the machine only
understands that! Isn't there another way?
Isn't there another way? 11
Yes, the solution is: a translator!
Instead of learning Machine language, we prefer simpler
languages (programming languages: Pascal, C, Python, Java,
...), then we go through a translation phase to reach Machine
language.

The translation phase is generally ensured by a program called


a Compiler.
A Compiler is a program that translates source code
(understandable by humans) into binary code
(understandable by machines). The goal is to generate a
program to be executing by a computer.

But which programming language should we learn?


12
We can choose any language.
But the most important thing is to know how to present a
solution to a given problem, so that the machine can execute it.

Is the purpose of the module

ALGORITHMICS
Course Objective
• Learn the basic concepts of algorithmics and
programming.
• Be able to implement these concepts to analyze
simple problems and write corresponding
programs.
• Learn the C programming language.
13
Steps for resolving a problem
Problem analysis : What do we want to achieve?
Define the data: Describe their characteristics and types.
Define the results: Describe their characteristics and types.
Define the relationships between results and How do we go from
data to results?
Example :Prepare one liter of natural orange juice at 60%
concentrated.
Analysis
The preparation of a natural orange juice juice at 60% concentration
consists of extracting 60 cl of juice from the orange fruit, then adding
40 cl of water.
To sweeten it, you can add honey or dates.

14
The data
5 to 8 oranges, depending on their juiciness, 40 cl of water Honey or
a few dates, depending on taste preference.
In addition to tools: knife, press (or blender), container, bottle,
strainer, funnel.
The result
1liter of juice (liquid) concentrated at 60%.
Relations between results and data
To pass from data to result, we execute the following actions :
1- Wash oranges if they are not clean.
2- Cut them in half for a press or peel and cut them into pieces if using
a blender, and remove any seeds.
3- If using dates, remove the pits and cut them into pieces. .
4- Press the oranges or mixe oranges and dates with water
(depending on the tool using).
15
5-If we use a press, dilute honey in water.
6-Put all in the container.
7-Pour into the bottle through the funnel. Use the strainer if you
want clear juice.

That's what we call

An Algorithm
Definition
An algorithm is a finite sequence of elementary actions executed in
a specific order on a set of data, to solve a problem.

For a computer problem


The analysis consists of:
16
Define all the objects used to represent input data and output
results
Define all the elementary actions that will be executed in a specific
order to achieve results.
What is an object?
An object is the entity manipulated by an action. There are two
classes of objects: constants and the variables.
Example
The action S = A + 2 manipulates three objects. 2 variable objects (S
and A) and an one constant object(2).
What is the difference between variable and constant?
A variable can change its value during the algorithm and can be
modified . (it's like oranges).
On the other hand, a constant, keeps the same value throughout the
execution of the algorithm. (it's like the knife)
17
Characteristics of an Object
An object is characterized by:
1- Name: called an identifier, it allows the object to be identified.
2- Type: the set of values that an object can take (real,
integer, character…), known as its domain of definition.
3- Value: an element of the type taken at a given time.
Example
Name : Age
Type: Integer
Value: 18
Identifiers Naming Rules
An identifier must follow certain construction rules:
-It is formed from alphabet characters (A to Z or a to z), digits (0 to 9),
and the underscore character (_)
-It can be at least one character long.
-The first character must be a letter.
18
Example
Correct identifiers: TTC, Gr3, sect, Nom_Et, Note_1_2_3, X, y
Incorrect identifiers: 9TH, Gr 3, S?, Nom-Et

Recommendations
-It's preferable to choose meaningful names..
-Some words are not allowed (see reserved keywords).
- Avoid long names.

19
Algorithm Representation
Historically, there are two ways to represent an algorithm
1- Flowchart
It is a graphical representation using symbols.
Begin or End

Inputs / Outputs

Processes

Tests

Sequence of Actions

Provides an overview of the algorithm. but is almost abandoned


today. 20
Example
Solve an equation: A x + B = 0
It is a first degree equation. His solution is –B/A provided that A ≠ 0.
If A is null, the equation does not have solution in R.
Begin

A,B

No Yes
X = -B/A A=0 Display 'No solution'

Display X

End

21
2- Algorithm
It is a standardized textual representation.
The general structure of an algorithm looks like a cooking recipe, and
consists of three parts.

Title Header

Ingredients Declarations

Preparation Actions

22
Header section
It’s used to define the name of the algorithm. For this we use a
keyword: Algorithm, and use it following a syntax that must be
respected.
Algorithm<AlgoName>;
<AlgoName>: This is an identifier representing the name of the
algorithm. We can choose any name, but it's preferable that it is
descriptive.

Example
Algorithm Invoice;
Algorithm Equation;
Algorithm Calculate_Sum;

23
Declaration section

In this section, we declare all the objects used in the algorithm


(constants and variables) by specifying two characteristics:
• The name and type for variables.
• The name and value for constants.
The declaration syntax for both types of objects is as follows:
Const<IdObj>= <ObjValue>;
Var<IdObj>: <ObjType>;
<IdObj>: is the identifier of the object.
<ObjValue>: is the value of the object
<ObjType>: is the type of the object.
Example : Const Pi=3.141592 ; Var Age:Integer ;
Note :Objects of the same type can be grouped together:
Example: Var Note1, Note2, Average : real ;
24

You might also like