Report On Algorithms
Report On Algorithms
INTRODUCTION TO ALGORITHMS
1. What is analysis?
Analysis: Distinction and separation of the parts of a whole until reaching an understanding of the principles or
elements of this.
Design: Design is defined as the prior process of mental configuration, "pre-figuration", in the
search for a solution in any field. Commonly used in the context of
industry, engineering, architecture, communication, and other creative disciplines.
Algorithm: An algorithm is like an ordered and finite set of operations that allows finding the
solution to a problem.
The analysis and design of algorithms aims to establish properties regarding efficiency.
allowing the comparison between alternative solutions and predicting the resources that will be used by a
algorithm. These estimates turn out to be quite useful in the search for efficient algorithms.
Exact measures of efficiency are useful for those who truly implement and use them.
algorithms, because they have more precision and thus allow them to know how much time they can assume that
it will take execution. For some people, like video game developers, a
A hidden constant can mean the difference between success and failure.
3. Origin of algorithms
These arose in the mid-9th century by the distinguished mathematician and astronomer Mohammed Ibn
Musa -aljarizm: but we can see that Al_yebr-mugabata is another who developed formulas for
enable that with a limited number of processes it was possible to solve first-degree equations and
second grade.
The history of the algorithm originates from the need to perform mathematical calculations through it.
it underpins the initial step of fully understanding any presented problem.
Analysis and Design of Algorithms
But let's also keep in mind that algorithms are at the very heart of
computers and that programming languages are just a means of expressing them.
4. Evolution of algorithms
To see the evolution that algorithms have undergone over the years, it is necessary to understand
that these evolved according to the computing needs and the physical architecture of the
computers, various problems require different approaches to solve them
virtually gave rise to the different programming paradigms.
Imperative Paradigm
Declarative Paradigm
Structured Paradigm
Object-Oriented Paradigm:
Functional Paradigm
Logical paradigm
Each paradigm has a different approach and is oriented towards a specific group of problems.
the characteristics that these paradigms have are:
Declarative Paradigm: It does not rely on how something is done (how a goal is achieved step by step.
step), but rather describes (declares) what something is like. In other words, it focuses on describing the
properties of the sought solution, leaving the algorithm undetermined (set of
instructions) used to find that solution. It is more complicated to implement than the
imperative paradigm has disadvantages in efficiency, but advantages in problem-solving
certain problems.
Structured Paradigm: programming is divided into blocks (procedures and functions) that
they can or cannot communicate with each other. In addition, the programming is controlled with sequence, selection
and iteration. It allows for the reuse of programmed code and provides a better understanding of the
programming. It is contrary to the unstructured paradigm, of little use, which has no
structure, it is simply a 'block', like for example, batch files (.bat).
Its main advantage is the reuse of codes and its ease of thinking of solutions to
certain problems.
Logical paradigm: it is based on the definition of logical rules and then, through an engine of
logical inferences, answer questions posed to the system and thus solve problems.
Example: prologue.
5. Structure of an algorithm
The structure of an algorithm helps to organize the elements that appear in it. All the
algorithms have the same structure, which is defined by three sections:
· Header
· Statements
· Body
Header: The header of an algorithm must indicate the name (identifier) assigned to it.
same. The syntax is: 'Algorithm <algorithm_name>'.
Example:
If one wants to design the algorithm of a program that calculates the area of a circle by
the algorithm must have "algorithm Area_of_a_circle" in the header
Declarations: In this section, the constants, data types, and variables are declared that
they are used in an algorithm. The syntax is as follows:
Constants
<declaration_of_constants>
Data types
Variables
<variable_declaration>
Analysis and Design of Algorithms
Example:
To solve the problem posed in the previous topic, it is necessary to declare a constant and
two variables
Constants
PI=3.1416
Variables
Body: In the body, all the instructions of the algorithm are written. The syntax is:
Start
Instruction 1
Instruction n
End
Start and End are reserved words that mark the beginning and the end of the body section.
what is where the main instruction block of the algorithm is.
Example
Start
Leer (radio)
Area = PI * radius ** 2
End
Example
/* Header */
Algorithm Area_of_a_circle
Algorithm Analysis and Design
6. Types of algorithms
Qualitative: They are those in which the steps are described using words.
Quantitative: These are the ones in which numerical calculations are used to define the steps of
process.
There are several algorithm design techniques that allow for the development of a solution to the problem.
proposed, some of them are:
Greedy algorithms: they select the most promising elements from the set of
candidates until a solution is found. In most cases, the solution is not optimal.
Parallel algorithms: allow the division of a problem into subproblems in such a way that it
can be executed simultaneously on several processors.
Deterministic algorithms: The behavior of the algorithm is linear: each step of the algorithm
has only one successor and one ancestor.
Non-deterministic algorithms: The behavior of the algorithm takes the form of a tree and at each
the step of the algorithm can branch into any number of immediately subsequent steps,
In addition, all branches are executed simultaneously.
Divide and conquer: they divide the problem into disjoint subsets obtaining a solution of
each of them to later join them, thus achieving the solution to the complete problem.
It is the execution of the instructions of an exe by the CPU. It is then when the processor
access the machine code of the program and execute its actions sequentially.
Analysis and Design of Algorithms
In this way, the programmer executes a cold run on the source program by selecting
a set of input data, manually executing each statement of the source program and
checking that the results obtained are as expected according to the dataset
input. As a debugging technique, the programmer must carry out this process using
datasets that allow executing all possible "paths" of the program.
Example: Perform the E-P-S analysis and design an algorithm to calculate the surface area of a
parallelepiped with dimensions l (length), a (width), and h (height).
Encoding:
float Area()
{
float l, h, a, AS;
Length of the parallelepiped =
scanf("%f", &l);
Width of the parallelepiped=
scanf("%f", &a);
Height of the parallelepiped=
scanf("%f", &h);
AS = 2 * (l * a + l * h + a * h);
printf("Surface area of the parallelepiped = %f", AS);
}
Cold running:
l = 3.0
a = 2.5
h = 7.3
AS = 2 x (3.0 x 2.5 + 3.0 x 7.3 +
(2.5 x 7.3) = 95.3
Analysis and Design of Algorithms
9. Examples of an algorithm.
1- In order for a person to exercise their vote in a government election, they must be of legal age.
age and Costa Rican.
For a person to be able to marry, they must be of legal age and single.
3- Write an algorithm that calculates the hypotenuse of a right triangle, where both legs
they are equal to 5.
Analysis and Design of Algorithms
BIBLIOGRAPHY
http://es.scribd.com/doc/33942225/Algorithmic-and-programming-project-1