Time Complexity of A Program
Time Complexity of A Program
Introduction To Algorithms
1
Today’s Contents
• What is an Algorithm?
2
3
What is Algorithm?
• A step-by-step procedure or formula for solving a problem or
performing a task.
•Example: A recipe to bake a cake is an algorithm.
▪ It is a logical and mathematical approach to solve or crack a
problem using any possible method.
4
Advantages for Algorithm
5
Criteria of a Algorithm
6
Basic Properties of Algorithms:
• Correctness: Produces the right output for
all valid inputs.
• Efficiency: Makes optimal use of resources
(time and space).
• Finiteness: Terminates after a finite
number of steps.
• Clarity: Easily understandable and
modifiable
7
Different types of Algorithms
8
Different types of Algorithms
1. Searching Algorithms
2. Sorting Algorithms
3. Divide and conquer algorithms
4. Recursive algorithms
5. Backtracking algorithms
6. Brute force algorithms
7. Greedy Algorithms
8. Dynamic programming algorithms
9
Application of Algorithms
1. Searching Data
2. Sorting Data
3. Find out the Shortest Path
4. Best Possible solution
10
Some Real Life Examples
11
Some Real Life Examples
▪ Search Engine (Google, Microsoft Edge, Mozilla, Opera etc)
▪ Social networking (Facebook)
▪ Travelling route (Air Flight route, Google Map, Shipping route etc)
▪ Facial Recognition Algorithm
▪ Genetic Engineering
▪ Stock Market
▪ Artificial Intelligence
▪ Machine Learning
▪ Robotics
12
How to Write an Algorithm?
▪ There are no well-defined standards for writing algorithms.
▪ Rather, it is problem and resource dependent.
13
finding the maximum
number in a list of
numbers:
14
basic sorting algorithm like
Bubble Sort:
15
Live Demo Using Interactive
Tools:
You can find videos that visually demonstrate sorting algorithms on
platforms like YouTube.
•Websites like VisuAlgo and SortingVisualizer also have interactive
visualizations for various algorithms.
•https://www.hackerearth.com/
16
Thank you!
17