You are on page 1of 9

Introduction to Algorithm

 An algorithm
Topic/Course is a set of well-defined instructions or a sequence of steps
that are used to solve a specific problem or accomplish a particular task.

 Algorithms are used extensively in computer science and programming


to solve problems and automate tasks.

 An algorithm is typically designed to perform a specific task or solve a


specific problem, and it can be expressed in various ways, such as
natural language, pseudocode, flowcharts, or programming languages.
 The efficiency and correctness of an algorithm are crucial factors in computer
science, as they can greatly impact the performance of a program.
Topic/Course
 Efficient algorithms are designed to execute quickly and consume minimal
resources, while correct algorithms always produce the expected output for a
given input.

 There are many different types of algorithms, such as sorting algorithms,


searching algorithms, graph algorithms, and many others.

 Each algorithm has its unique characteristics, and it is essential to choose the
appropriate algorithm for a specific problem to ensure optimal performance.
We need algorithms because of the following reasons:
Topic/Course
 Scalability: It helps us to understand the scalability. When we
have a big real-world problem, we need to scale it down into
small-small steps to easily analyze the problem.

 Performance: The real-world is not easily broken down into


smaller steps. If the problem can be easily broken into smaller
steps means that the problem is feasible.
Characteristics of Algorithm
• Clear and Unambiguous: Algorithm should be clear and unambiguous. Each of its steps
should be clear in all aspects and must lead to only one meaning.

• Well-Defined Inputs: If an algorithm says to take inputs, it should be well-defined inputs.

• Well-Defined Outputs: The algorithm must clearly define what output will be yielded and it
should be well-defined as well.

• Finiteness: The algorithm must be finite, i.e. it should not end up in an infinite loops or similar.

• Feasible: The algorithm must be simple, generic and practical, such that it can be executed
upon will the available resources.

• 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
same, as expected.
Dataflow of an Algorithm
• Problem: A problem can be a real-world problem or any instance from
the real-worldTopic/Course
problem for which we need to create a program or the set
of instructions. The set of instructions is known as an algorithm.

• Algorithm: An algorithm will be designed for a problem which is a step


by step procedure.

• Input: After designing an algorithm, the required and the desired inputs
are provided to the algorithm.

• Processing unit: The input will be given to the processing unit, and the
processing unit will produce the desired output.

• Output: The output is the outcome or the result of the program.

On the right side, the flow of Euclid’s algorithm to calculate GCD of two
numbers are given.
How to design algorithms:

As we know that an algorithm is a step-by-step procedure so


Topic/Course
we must follow some steps to design an algorithm.

Designing algorithm is not a one step process, we need


different approaches for different algorithms

How to analyse algorithm efficiency

We cannot determine efficiency of an algorithm by


benchmarking its speed. We need a sophisticated method to
analyse an efficiency of an algorithm.
MCQ’s
Topic/Course

What is an algorithm?
a) A computer program
b) A set of instructions to solve a problem
c) A programming language
d) A computer hardware component
THANK YOU

You might also like