Algorithms by Ammar Mussab

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Algorithms

By Ammar Mussab
What we are going to learn
Methods for
Intro to Algorithms expressing Algorithms
01 What do we mean when we 04 How can we express
say the word algorithms? algorithms?

Flowcharts & pseudo


Properties code
02 What makes an algorithm and 05 Get to know some of the
what must it contain? most common ways used to
express algorithms

Benefits Summary
03 The benefits of algorithms. 06 All of this might be a lot to
There are too many! take in at once so why not
review so we can get a better
understanding?
2
01 Introduction
Before there were computers, there were algorithms. But
now that there are computers, there are even more
algorithms, and algorithms lie at the heart of computing.

In Computer Science an algorithm is an effective, efficient


and the best method which can be used to express solution
of any problem within a finite amount of space and time and
in a well-defined formal language.

Finding good algorithms and knowing how to apply them


allows for interesting and important programs

One of the most obvious examples of an algorithm is a


recipe. It's a finite list of instructions used to perform a task

3
“Anyone, from the most clueless amateur
to the best cryptographer, can create an
algorithm that he himself can't break."

-Bruce Schneier
4
WHAT MAKES A GOOD ALGORITHM ?

Precision – the steps are precisely


stated(defined)

Uniqueness – results of each step are uniquely


defined and only depend on the input and the
result of the proceeding steps.

Finiteness – the algorithm stops after a finite


number of instructions are executed.

Input – the algorithm receives input.

• Selection Sort

• Insertion Sort

• Merge Sort 5
Properties of algorithms
Non-Ambiguity Range of Input
The proper instruction in any algorithm should
not show any conflicting meaning. This The range of input should be specified. This is
property also indicates the effectiveness of because normally the algorithm is input driven and
the algorithm. That means each instruction if the range of input is not being specified then
should be direct and precise. Each Each key algorithm can go in an infinite state.
step in a developed algorithm should be non-
ambiguous.
Speed
The algorithm is carefully invented reliably using
Multiplicity some specified ideas. But such
The same algorithm can be represented into algorithms, should be efficient
several alternative and should produce the output with tremendous
ways. That means we can write in simple speed.
English the sequence of instruction, Finiteness
or we can note it in form of pseudo
code. Likewise, for solving the same problem, The algorithm should be finite. That means after
we can write several modified algorithms. performing required operations it
should terminate.
6
3 Benefits of Algorithms
Better problems solving: The identification of decision points and process divides the task into various
slighter steps that are more manageable. this means problems that would normally have been impossible
or difficult to resolve wholesale are going to be approached like a series of much smaller and
solvable problems.

Improving efficiency: Algorithms make decision making more consistent and more efficient. An
algorithm acts like a reminder device and assists in making sure that all variables or small parts of a
certain problem or task are not overlooked. Eventually, algorithms promote expertise development as it
facilitates the division of work amongst the employees.

Provides clarity
If a problem solver is not aware of what was performed, it is likely that she or he will not be aware of
what went wrong. The presence of a detailed solution process enables easier identification of errors and
weaknesses in the whole process. Reducing a vital task to several specified steps through using algorithm
provides clarity and it is a critical part of evaluation, control and analysis.

7
4 Methods of Expressing Algorithms

We can express an algorithm many ways, including natural language, flow charts,
pseudocode, and of course, actual programming languages.

Ways of writing an algorithm:

English-Like Algorithm. An algorithm can be written in many ways. It can be written in


simple English but this method also has some demerits. ...

Flowchart. Flowcharts pictorially depict a process. ...

Pseudocode. The pseudocode has an advantage of being easily converted into any
programming language.

8
5 Overview of Two Methods
1) Pseudocode
Pseudocode :Pseudocode is an artificial and informal language that helps programmers develop
algorithms. Pseudocode is a "text-based" detail (algorithmic) design tool. The direct rules of
Pseudocode are reasonably straightforward. All statements showing "dependency" are to be
indented. These include while, do, for, if and switch. Its essentially English with some defined
rules of structure and some keywords that make it appear a bit like program code.

Pseudocode is not actual programming language. It uses short phrases to write code for
programs

Designing an algorithm in pseudo-code has advantages because:

it can be quickly and easily converted into an actual programming language as it is similar to a
programming language.

it is fairly easy to understand, even for non-programmers.

9
6 2) Flowcharts

A flowchart is a picture (graphical representation) of the problem solving process.

A flowchart gives a step-by-step procedure for solution of a problem.

Elements of a flowchart:

Various geometrical shaped boxes represent the steps of the solution.

The boxes are connected by directional arrows to show the flow of the solution.

Uses of a flowchart:

1)We use flowcharts to specify the method of solving a problem

2) It also helps in planning the sequence of a computer program.

3)Flowcharts are also a way to communicate ideas and solutions.


10
Summary
• There are two main ways that algorithms can
• In mathematics and computer science, an be represented – pseudocode and flowcharts
algorithm is a finite sequence of well-defined,
computer-implementable instructions, • The properties of an algorithm:
typically to solve a class of problems or to
perform a computation Input: The algorithm must have input values from a
specified set.

Output: The algorithm must produce the output values


• Algorithms are very important in computer from a specified set of input values. The output values
Science. The best chosen algorithm makes are the solution to a problem.
sure computer will do the given task at best
possible manner. In cases where efficiency Finiteness: For any input, the algorithm must
matter a proper algorithm is really vital to be terminate after a finite number of steps.
used.

11

A M MA R M U SSA B

GIFTED STUDENTS SCHOOL

A M M A R . A L A Z I Z @ I R AQ I G G C . E D U. I Q

BASRA, IRAQ

Thank You!
This Presentation was created on 24/12/2020

You might also like