0% found this document useful (0 votes)
18 views19 pages

ALGORITHM

An algorithm is a defined process or set of instructions used to solve problems or perform calculations across various fields such as computer science, mathematics, and artificial intelligence. Key characteristics of algorithms include clarity, feasibility, language independence, and effectiveness, while types of algorithms range from brute force to dynamic programming. Designing and analyzing algorithms involves understanding the problem, constraints, inputs, and expected outputs, with methods for expression including natural language, flow charts, and pseudo code.

Uploaded by

Robert Luzabe
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)
18 views19 pages

ALGORITHM

An algorithm is a defined process or set of instructions used to solve problems or perform calculations across various fields such as computer science, mathematics, and artificial intelligence. Key characteristics of algorithms include clarity, feasibility, language independence, and effectiveness, while types of algorithms range from brute force to dynamic programming. Designing and analyzing algorithms involves understanding the problem, constraints, inputs, and expected outputs, with methods for expression including natural language, flow charts, and pseudo code.

Uploaded by

Robert Luzabe
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/ 19

ALGORITH

M
• Algorithm is defined as a process or set of well-defined
instructions that are typically used to solve a particular group of
problems or perform a specific type of calculation.
ALGORITHM
• It is a set of operations performed in a step-by-step manner to
execute a task.
USES OF ALGORITHM

Computer Science: Mathematics: Operations Research: Artificial Intelligence: Data Science:


Algorithms form the basis of Algorithms are used to Algorithms are used to Algorithms are the foundation Algorithms are used to
computer programming and solve mathematical optimize and make of artificial intelligence and analyze, process, and
are used to solve problems problems, such as finding decisions in fields such as machine learning and are used extract insights from large
ranging from simple sorting the optimal solution to a transportation, logistics, to develop intelligent systems amounts of data in fields
and searching to complex system of linear equations and resource allocation. that can perform tasks such as such as marketing, finance,
tasks such as artificial or finding the shortest path image recognition, natural and healthcare.
intelligence and machine in a graph. language processing, and
learning. decision-making.
• Algorithms are necessary for solving complex problems efficiently
and effectively.

WHAT IS THE They help to automate processes and make them more reliable, faster, and
easier to perform.
NEED FOR • Algorithms also enable computers to perform tasks that would be
ALGORITHMS? difficult or impossible for humans to do manually.

They are used in various fields such as mathematics, computer science,


engineering, finance, and many others to optimize processes, analyze data,
make predictions, and provide solutions to problems.
WHAT ARE THE CHARACTERISTICS
OF AN ALGORITHM?
• Clear and Unambiguous:
• The algorithm should be unambiguous. Each of its steps should be clear
in all aspects and must lead to only one meaning.

• Feasible:
• The algorithm must be simple, generic, and practical, such that it can be
executed with the available resources. It must not contain some future
technology or anything.

• Language Independent:
• The Algorithm designed must be language-independent, i.e. it must be
just plain instructions that can be implemented in any language, and yet
the output will be the same, as expected.
• Input:

• An algorithm has zero or more inputs. Each that contains a


fundamental operator must accept zero or more inputs.

• Output:

• An algorithm produces at least one output. Every instruction that


contains a fundamental operator must accept zero or more inputs.

• Definiteness:

• All instructions in an algorithm must be unambiguous, precise, and


easy to interpret. By referring to any of the instructions in an algorithm
one can clearly understand what is to be done. Every fundamental
operator in instruction must be defined without any ambiguity.
• Finiteness:

• An algorithm must terminate after a finite number of steps in all test cases.
Every instruction which contains a fundamental operator must be terminated
within a finite amount of time. Infinite loops or recursive functions without
base conditions do not possess finiteness.

• Effectiveness:

• An algorithm must be developed by using very basic, simple, and feasible


operations so that one can trace it out by using just paper and pencil.
• It should terminate after a finite time.

• It should produce at least one output.

PROPERTIES OF • It should take zero or more input.

AN ALGORITHM
• It should be deterministic, giving the same output for
the same input case.

• Every step in the algorithm must be effective (every


step should do some work)
TYPES OF ALGORITHMS
1. Brute Force Algorithm:

It is the simplest approach to a problem. A brute force algorithm is the first approach that
comes to finding when we see a problem.

2. Recursive Algorithm:

A recursive algorithm is based on recursion. In this case, a problem is broken into several
sub-parts and called the same function again and again.

3. Backtracking Algorithm:

The backtracking algorithm builds the solution by searching among all possible solutions.
Using this algorithm, we keep on building the solution following criteria. Whenever a
solution fails we trace back to the failure point build on the next solution and continue this
process till we find the solution or all possible solutions are looked after.
4. Searching Algorithm:

Searching algorithms are the ones that are used for searching elements or groups
of elements from a particular data structure. They can be of different types based
on their approach or the data structure in which the element should be found

5. Sorting Algorithm:

Sorting is arranging a group of data in a particular manner according to the


requirement. The algorithms which help in performing this function are called
sorting algorithms. Generally sorting algorithms are used to sort groups of data in
an increasing or decreasing manner.

6. Hashing Algorithm:

Hashing algorithms work similarly to the searching algorithm. But they contain an
index with a key ID. In hashing, a key is assigned to specific data
7.Divide and Conquer Algorithm:
This algorithm breaks a problem into sub-problems, solves a single sub-problem, and
merges the solutions to get the final solution. It consists of the following three steps:

• Divide – dividing the problem into smaller sub-problems.

• Solve – Solve sub-problems by calling recursively until solved

• Combine – Combine the sub-problems to get the final solution of the whole
problem.

8. Greedy Algorithm:
In this type of algorithm, the solution is built part by part. The solution for the next
part is built based on the immediate benefit of the next part. The one solution that
gives the most benefit will be chosen as the solution for the next part.
9. Dynamic Programming Algorithm:

This algorithm uses the concept of using the already found solution
to avoid repetitive calculation of the same part of the problem. It
divides the problem into smaller overlapping subproblems and
solves them.

10. Randomized Algorithm:

In the randomized algorithm, we use a random number so that it


gives immediate benefit. The random number helps in deciding the
expected outcome.
HOW TO DESIGN AN ALGORITHM?
To write an algorithm, the following things are needed as a pre-requisite

• The problem that is to be solved by this algorithm.

• The constraints of the problem must be considered while solving the problem.

• The input to be taken to solve the problem.

• The output is to be expected when the problem is solved.

• The solution to this problem is within the given constraints.

Then the algorithm is written with the help of the above parameters such that it solves the problem.
HOW TO ANALYZE
AN ALGORITHM?
For a standard algorithm to be good, it must be efficient. Hence the efficiency of an
algorithm must be checked and maintained. It can be in two stages:

1. Priori Analysis:

“Priori” means “before”. Hence Priori analysis means checking the algorithm
before its implementation. In this, the algorithm is checked when it is written in the
form of theoretical steps.

This is done usually by the algorithm designer. This analysis is independent of the
type of hardware and language of the compiler. It gives the approximate answers
for the complexity of the program.
2. Posterior Analysis:
“Posterior” means “after”. Hence Posterior analysis means checking
the algorithm after its implementation. In this, the algorithm is checked
by implementing it in any programming language and execute it.

This analysis helps to get the actual and real analysis report about
correctness(for every possible input/s if it shows/returns correct output
or not), space required, time consumed, etc.

That is, it is dependent on the language of the compiler and the type of
hardware used.
HOW TO EXPRESS AN
ALGORITHM?
• Natural Language:

• We express the Algorithm in the natural English language or other languages. It is too hard to understand the algorithm
from it.

• Flow Chart:

• Here we express the Algorithm by making a graphical/pictorial representation of it. It is easier to understand than Natural
Language.

• Pseudo Code:

• Here we express the Algorithm in the form of annotations and informative text written in plain English which is very much
similar to the real code but as it has no syntax like any of the programming languages, it can’t be compiled or interpreted
by the computer. It is the best way to express an algorithm because it can be understood by even a layman with some
school-level knowledge.
It is easy to understand.

ADVANTAGES
An algorithm is a step-wise
OF representation of a solution to a given
problem.
ALGORITHMS

In an Algorithm the problem is broken


down into smaller pieces or steps
hence, it is easier for the programmer to
convert it into an actual program.
WRITING AN ALGORITHM UNDERSTANDING COMPLEX
DISADVANTAGES TAKES A LONG TIME SO IT IS
TIME-CONSUMING.
LOGIC THROUGH ALGORITHMS
CAN BE VERY DIFFICULT.
OF
ALGORITHMS

BRANCHING AND LOOPING


STATEMENTS ARE DIFFICULT
TO SHOW IN ALGORITHMS.
FIN

You might also like