SlideShare a Scribd company logo
Module I
Introduction to Algorithm
What is an Algorithm?
• An algorithm is a sequence of unambiguous instructions for
solving a problem, i.e., for obtaining a required output for any
legitimate input in a finite amount of time.
HISTORICAL PERSPECTIVE
• Euclid’s algorithm for finding the greatest common
divisor
• One of the oldest algorithms known (300 BC)
• Muhammad ibn Musa al-Khwarizmi – 9th century
mathematician
• Al-Khwarizmi principle states that all complex
problems of science must be and can be solved by
means of five simple steps
Notion of Algorithm
Algorithmic solution
“Computer”
input output
proble
m
algorithm
Example: Sorting
• Statement of problem:
• Input:
• A Sequence of n numbers < a1 , a2,a3 …….,a4 >
• Output:
• A reordering of n numbers < b1, b2 ,b3, ….bn >
• So that 𝑏𝑖 ≤ 𝑏𝑗 ,whenever i ≤ j
Example:
“Computer”
input output
proble
m
algorithm
Algorithmic solution
Sorting Algorithm
• Selection Sort ?
• Insertion Sort ?
• Merge Sort ?
• ….
< 5, 3, 2, 1, 8, 6 > < 1, 2, 3, 5, 6, 8
>
Performance Analysis of an algorithm
• Performance of an algorithm is a process of making evaluative
judgement about algorithms.
• Performance of an algorithm means predicting the resources which
are required to an algorithm to perform its task.
Performance Analysis (cont.)
• An algorithm is said to be efficient and fast, if it takes less time
to execute and consumes less memory space. The
performance of an algorithm is measured on the basis of
following properties :
• 1. Time Complexity
• 2. Space Complexity
Growth of some typical functions
Functions of the form log k, n,cn,cn2 ,cn3 are called, respectively, logarithmic, linear,
quadratic and cubic
Three Asymptotic Notation
• The O-notation , O(n2) (read “Oh of n2 ”or “big-Oh of n2 ”)
• The Ω-notation, Ω(n) (read “omega of n”, or “big-omega of n”)
• The Θ-notation , Θ(n2) (read “theta of n2 ”)
The O-notation
• In general, we say that the running time of an algorithm is O(g(n)), if
whenever the input size is equal to or exceeds some threshold n0 , its
running time can be bounded above by some positive constant c times g(n).
• Definition: Let f(n) and g(n) be two functions from the set of natural
numbers to the set of nonnegative real numbers. f(n) is said to be O(g(n)) if
there exists a natural number n0 and a constant c > 0 such that
∀ n ≥ n0 , f(n) ≤ cg(n).
Consequently, if lim
𝑛→∞
𝑓(𝑛)
𝑔(𝑛)
exists, then
if lim
𝑛→∞
𝑓(𝑛)
𝑔(𝑛)
≠ ∞ implies f(n) = O(g(n)).
TIME COMPLEXITY
• The time complexity of an algorithm is the total amount of time
required by an algorithm to complete its execution.
• If any program requires fixed amount of time for all input values then
its time complexity is said to be Constant Time Complexity
int sum(int a, int b)
{
return a+b;
}
SPACE COMPLEXITY
• We define the space used by an algorithm to be the number of
memory cells (or words) needed to carry out the computational
steps required to solve an instance of the problem excluding the
space allocated to hold the input.
• All definitions of order of growth and asymptotic bounds
pertaining to time complexity carry over to space complexity. It
is clear that the work space cannot exceed the running time of
an algorithm, as writing into each memory cell requires at least
a constant amount of time.
Introduction to Algorithm
Introduction to Algorithm

More Related Content

What's hot

Algorithm big o
Algorithm big oAlgorithm big o
Algorithm big o
Ashim Lamichhane
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notationsEhtisham Ali
 
Daa unit 1
Daa unit 1Daa unit 1
Daa unit 1
Abhimanyu Mishra
 
Lecture 2 role of algorithms in computing
Lecture 2   role of algorithms in computingLecture 2   role of algorithms in computing
Lecture 2 role of algorithms in computing
jayavignesh86
 
Online algorithms and their applications
Online algorithms and their applicationsOnline algorithms and their applications
Online algorithms and their applications
Vikas Jindal
 
Unit 1 chapter 1 Design and Analysis of Algorithms
Unit 1   chapter 1 Design and Analysis of AlgorithmsUnit 1   chapter 1 Design and Analysis of Algorithms
Unit 1 chapter 1 Design and Analysis of Algorithms
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
Introduction to design and analysis of algorithm
Introduction to design and analysis of algorithmIntroduction to design and analysis of algorithm
Introduction to design and analysis of algorithm
DevaKumari Vijay
 
Daa notes 1
Daa notes 1Daa notes 1
Daa notes 1
smruti sarangi
 
Algorithm
AlgorithmAlgorithm
Algorithm
IHTISHAM UL HAQ
 
Design and analysis of algorithms
Design and analysis of algorithmsDesign and analysis of algorithms
Design and analysis of algorithms
Dr Geetha Mohan
 
Symbol Table
Symbol TableSymbol Table
Symbol Table
Akhil Kaushik
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
mustafa sarac
 
Data Structures - Lecture 1 [introduction]
Data Structures - Lecture 1 [introduction]Data Structures - Lecture 1 [introduction]
Data Structures - Lecture 1 [introduction]
Muhammad Hammad Waseem
 
Time complexity.ppt
Time complexity.pptTime complexity.ppt
Time complexity.ppt
YekoyeTigabuYeko
 
Data Structure: Algorithm and analysis
Data Structure: Algorithm and analysisData Structure: Algorithm and analysis
Data Structure: Algorithm and analysis
Dr. Rajdeep Chatterjee
 
Bca ii dfs u-3 tree and graph
Bca  ii dfs u-3 tree and graphBca  ii dfs u-3 tree and graph
Bca ii dfs u-3 tree and graph
Rai University
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.ppt
racha49
 
Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis
Dr. Pankaj Agarwal
 
Solving problems by searching
Solving problems by searchingSolving problems by searching
Solving problems by searchingLuigi Ceccaroni
 
Algorithm analysis
Algorithm analysisAlgorithm analysis
Algorithm analysissumitbardhan
 

What's hot (20)

Algorithm big o
Algorithm big oAlgorithm big o
Algorithm big o
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Daa unit 1
Daa unit 1Daa unit 1
Daa unit 1
 
Lecture 2 role of algorithms in computing
Lecture 2   role of algorithms in computingLecture 2   role of algorithms in computing
Lecture 2 role of algorithms in computing
 
Online algorithms and their applications
Online algorithms and their applicationsOnline algorithms and their applications
Online algorithms and their applications
 
Unit 1 chapter 1 Design and Analysis of Algorithms
Unit 1   chapter 1 Design and Analysis of AlgorithmsUnit 1   chapter 1 Design and Analysis of Algorithms
Unit 1 chapter 1 Design and Analysis of Algorithms
 
Introduction to design and analysis of algorithm
Introduction to design and analysis of algorithmIntroduction to design and analysis of algorithm
Introduction to design and analysis of algorithm
 
Daa notes 1
Daa notes 1Daa notes 1
Daa notes 1
 
Algorithm
AlgorithmAlgorithm
Algorithm
 
Design and analysis of algorithms
Design and analysis of algorithmsDesign and analysis of algorithms
Design and analysis of algorithms
 
Symbol Table
Symbol TableSymbol Table
Symbol Table
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
 
Data Structures - Lecture 1 [introduction]
Data Structures - Lecture 1 [introduction]Data Structures - Lecture 1 [introduction]
Data Structures - Lecture 1 [introduction]
 
Time complexity.ppt
Time complexity.pptTime complexity.ppt
Time complexity.ppt
 
Data Structure: Algorithm and analysis
Data Structure: Algorithm and analysisData Structure: Algorithm and analysis
Data Structure: Algorithm and analysis
 
Bca ii dfs u-3 tree and graph
Bca  ii dfs u-3 tree and graphBca  ii dfs u-3 tree and graph
Bca ii dfs u-3 tree and graph
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.ppt
 
Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis
 
Solving problems by searching
Solving problems by searchingSolving problems by searching
Solving problems by searching
 
Algorithm analysis
Algorithm analysisAlgorithm analysis
Algorithm analysis
 

Similar to Introduction to Algorithm

Analysis of algorithn class 3
Analysis of algorithn class 3Analysis of algorithn class 3
Analysis of algorithn class 3Kumar
 
Lec1
Lec1Lec1
Introducción al Análisis y diseño de algoritmos
Introducción al Análisis y diseño de algoritmosIntroducción al Análisis y diseño de algoritmos
Introducción al Análisis y diseño de algoritmos
luzenith_g
 
Algorithm
AlgorithmAlgorithm
Algorithm
Syam Kumar
 
Algorithm in Computer, Sorting and Notations
Algorithm in Computer, Sorting  and NotationsAlgorithm in Computer, Sorting  and Notations
Algorithm in Computer, Sorting and Notations
Abid Kohistani
 
how to calclute time complexity of algortihm
how to calclute time complexity of algortihmhow to calclute time complexity of algortihm
how to calclute time complexity of algortihmSajid Marwat
 
Annotations.pdf
Annotations.pdfAnnotations.pdf
Annotations.pdf
GauravKumar295392
 
Algorithm And analysis Lecture 03& 04-time complexity.
 Algorithm And analysis Lecture 03& 04-time complexity. Algorithm And analysis Lecture 03& 04-time complexity.
Algorithm And analysis Lecture 03& 04-time complexity.
Tariq Khan
 
asymptotic analysis and insertion sort analysis
asymptotic analysis and insertion sort analysisasymptotic analysis and insertion sort analysis
asymptotic analysis and insertion sort analysisAnindita Kundu
 
e.ppt
e.ppte.ppt
Introducction to Algorithm
Introducction to AlgorithmIntroducction to Algorithm
Introducction to Algorithm
Rajamanickam Gomathijayam
 
Advanced Datastructures and algorithms CP4151unit1b.pdf
Advanced Datastructures and algorithms CP4151unit1b.pdfAdvanced Datastructures and algorithms CP4151unit1b.pdf
Advanced Datastructures and algorithms CP4151unit1b.pdf
Sheba41
 
module1_Introductiontoalgorithms_2022.pdf
module1_Introductiontoalgorithms_2022.pdfmodule1_Introductiontoalgorithms_2022.pdf
module1_Introductiontoalgorithms_2022.pdf
Shiwani Gupta
 
Lec1
Lec1Lec1
Design and Analysis of Algorithms Lecture Notes
Design and Analysis of Algorithms Lecture NotesDesign and Analysis of Algorithms Lecture Notes
Design and Analysis of Algorithms Lecture Notes
Sreedhar Chowdam
 
Time and space complexity
Time and space complexityTime and space complexity
Time and space complexityAnkit Katiyar
 
DS Unit-1.pptx very easy to understand..
DS Unit-1.pptx very easy to understand..DS Unit-1.pptx very easy to understand..
DS Unit-1.pptx very easy to understand..
KarthikeyaLanka1
 
Daa unit 6_efficiency of algorithms
Daa unit 6_efficiency of algorithmsDaa unit 6_efficiency of algorithms
Daa unit 6_efficiency of algorithms
snehajiyani
 

Similar to Introduction to Algorithm (20)

Analysis of algorithn class 3
Analysis of algorithn class 3Analysis of algorithn class 3
Analysis of algorithn class 3
 
Lec1
Lec1Lec1
Lec1
 
Introducción al Análisis y diseño de algoritmos
Introducción al Análisis y diseño de algoritmosIntroducción al Análisis y diseño de algoritmos
Introducción al Análisis y diseño de algoritmos
 
Alg1
Alg1Alg1
Alg1
 
Algorithm
AlgorithmAlgorithm
Algorithm
 
Algorithm
AlgorithmAlgorithm
Algorithm
 
Algorithm in Computer, Sorting and Notations
Algorithm in Computer, Sorting  and NotationsAlgorithm in Computer, Sorting  and Notations
Algorithm in Computer, Sorting and Notations
 
how to calclute time complexity of algortihm
how to calclute time complexity of algortihmhow to calclute time complexity of algortihm
how to calclute time complexity of algortihm
 
Annotations.pdf
Annotations.pdfAnnotations.pdf
Annotations.pdf
 
Algorithm And analysis Lecture 03& 04-time complexity.
 Algorithm And analysis Lecture 03& 04-time complexity. Algorithm And analysis Lecture 03& 04-time complexity.
Algorithm And analysis Lecture 03& 04-time complexity.
 
asymptotic analysis and insertion sort analysis
asymptotic analysis and insertion sort analysisasymptotic analysis and insertion sort analysis
asymptotic analysis and insertion sort analysis
 
e.ppt
e.ppte.ppt
e.ppt
 
Introducction to Algorithm
Introducction to AlgorithmIntroducction to Algorithm
Introducction to Algorithm
 
Advanced Datastructures and algorithms CP4151unit1b.pdf
Advanced Datastructures and algorithms CP4151unit1b.pdfAdvanced Datastructures and algorithms CP4151unit1b.pdf
Advanced Datastructures and algorithms CP4151unit1b.pdf
 
module1_Introductiontoalgorithms_2022.pdf
module1_Introductiontoalgorithms_2022.pdfmodule1_Introductiontoalgorithms_2022.pdf
module1_Introductiontoalgorithms_2022.pdf
 
Lec1
Lec1Lec1
Lec1
 
Design and Analysis of Algorithms Lecture Notes
Design and Analysis of Algorithms Lecture NotesDesign and Analysis of Algorithms Lecture Notes
Design and Analysis of Algorithms Lecture Notes
 
Time and space complexity
Time and space complexityTime and space complexity
Time and space complexity
 
DS Unit-1.pptx very easy to understand..
DS Unit-1.pptx very easy to understand..DS Unit-1.pptx very easy to understand..
DS Unit-1.pptx very easy to understand..
 
Daa unit 6_efficiency of algorithms
Daa unit 6_efficiency of algorithmsDaa unit 6_efficiency of algorithms
Daa unit 6_efficiency of algorithms
 

More from Manash Kumar Mondal

Role of NDLI in Higher Education _ Research, KU.pdf
Role of NDLI in Higher Education _ Research, KU.pdfRole of NDLI in Higher Education _ Research, KU.pdf
Role of NDLI in Higher Education _ Research, KU.pdf
Manash Kumar Mondal
 
Various security issues and its solutions in the
Various security issues and its solutions in theVarious security issues and its solutions in the
Various security issues and its solutions in the
Manash Kumar Mondal
 
Omicron - A Covid 19 variant
Omicron - A Covid 19 variantOmicron - A Covid 19 variant
Omicron - A Covid 19 variant
Manash Kumar Mondal
 
Computer network
Computer networkComputer network
Computer network
Manash Kumar Mondal
 
Boolean alebra
Boolean alebraBoolean alebra
Boolean alebra
Manash Kumar Mondal
 
Tiny OS
Tiny OSTiny OS
File in C language
File in C languageFile in C language
File in C language
Manash Kumar Mondal
 
Pegasus, A spyware
Pegasus, A spywarePegasus, A spyware
Pegasus, A spyware
Manash Kumar Mondal
 
A comparative study between cloud computing and fog
A comparative study between cloud computing and fog A comparative study between cloud computing and fog
A comparative study between cloud computing and fog
Manash Kumar Mondal
 
Binary Semaphore
Binary SemaphoreBinary Semaphore
Binary Semaphore
Manash Kumar Mondal
 
Ocean- sat for Oceanography
Ocean- sat for Oceanography Ocean- sat for Oceanography
Ocean- sat for Oceanography
Manash Kumar Mondal
 
Graph theory
Graph  theoryGraph  theory
Graph theory
Manash Kumar Mondal
 
4 g and 5g Communication
4 g and 5g Communication4 g and 5g Communication
4 g and 5g Communication
Manash Kumar Mondal
 
Apache web service
Apache web serviceApache web service
Apache web service
Manash Kumar Mondal
 
Revolution of Mobile Communication, from 1G to 5G Communication
Revolution of Mobile Communication, from  1G to 5G CommunicationRevolution of Mobile Communication, from  1G to 5G Communication
Revolution of Mobile Communication, from 1G to 5G Communication
Manash Kumar Mondal
 
Introduction to Apache Web Services using latex
 Introduction to Apache Web Services using latex Introduction to Apache Web Services using latex
Introduction to Apache Web Services using latex
Manash Kumar Mondal
 
Cloud computing and Cloudsim
Cloud computing and CloudsimCloud computing and Cloudsim
Cloud computing and Cloudsim
Manash Kumar Mondal
 
Superscalar Processor
Superscalar ProcessorSuperscalar Processor
Superscalar Processor
Manash Kumar Mondal
 

More from Manash Kumar Mondal (18)

Role of NDLI in Higher Education _ Research, KU.pdf
Role of NDLI in Higher Education _ Research, KU.pdfRole of NDLI in Higher Education _ Research, KU.pdf
Role of NDLI in Higher Education _ Research, KU.pdf
 
Various security issues and its solutions in the
Various security issues and its solutions in theVarious security issues and its solutions in the
Various security issues and its solutions in the
 
Omicron - A Covid 19 variant
Omicron - A Covid 19 variantOmicron - A Covid 19 variant
Omicron - A Covid 19 variant
 
Computer network
Computer networkComputer network
Computer network
 
Boolean alebra
Boolean alebraBoolean alebra
Boolean alebra
 
Tiny OS
Tiny OSTiny OS
Tiny OS
 
File in C language
File in C languageFile in C language
File in C language
 
Pegasus, A spyware
Pegasus, A spywarePegasus, A spyware
Pegasus, A spyware
 
A comparative study between cloud computing and fog
A comparative study between cloud computing and fog A comparative study between cloud computing and fog
A comparative study between cloud computing and fog
 
Binary Semaphore
Binary SemaphoreBinary Semaphore
Binary Semaphore
 
Ocean- sat for Oceanography
Ocean- sat for Oceanography Ocean- sat for Oceanography
Ocean- sat for Oceanography
 
Graph theory
Graph  theoryGraph  theory
Graph theory
 
4 g and 5g Communication
4 g and 5g Communication4 g and 5g Communication
4 g and 5g Communication
 
Apache web service
Apache web serviceApache web service
Apache web service
 
Revolution of Mobile Communication, from 1G to 5G Communication
Revolution of Mobile Communication, from  1G to 5G CommunicationRevolution of Mobile Communication, from  1G to 5G Communication
Revolution of Mobile Communication, from 1G to 5G Communication
 
Introduction to Apache Web Services using latex
 Introduction to Apache Web Services using latex Introduction to Apache Web Services using latex
Introduction to Apache Web Services using latex
 
Cloud computing and Cloudsim
Cloud computing and CloudsimCloud computing and Cloudsim
Cloud computing and Cloudsim
 
Superscalar Processor
Superscalar ProcessorSuperscalar Processor
Superscalar Processor
 

Recently uploaded

Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
Kamal Acharya
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdf
Kamal Acharya
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
MuhammadTufail242431
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
Kamal Acharya
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
AafreenAbuthahir2
 
addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
ShahidSultan24
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
Kamal Acharya
 

Recently uploaded (20)

Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdf
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
 
addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
 

Introduction to Algorithm

  • 2. What is an Algorithm? • An algorithm is a sequence of unambiguous instructions for solving a problem, i.e., for obtaining a required output for any legitimate input in a finite amount of time.
  • 3. HISTORICAL PERSPECTIVE • Euclid’s algorithm for finding the greatest common divisor • One of the oldest algorithms known (300 BC) • Muhammad ibn Musa al-Khwarizmi – 9th century mathematician • Al-Khwarizmi principle states that all complex problems of science must be and can be solved by means of five simple steps
  • 4. Notion of Algorithm Algorithmic solution “Computer” input output proble m algorithm
  • 5. Example: Sorting • Statement of problem: • Input: • A Sequence of n numbers < a1 , a2,a3 …….,a4 > • Output: • A reordering of n numbers < b1, b2 ,b3, ….bn > • So that 𝑏𝑖 ≤ 𝑏𝑗 ,whenever i ≤ j
  • 6. Example: “Computer” input output proble m algorithm Algorithmic solution Sorting Algorithm • Selection Sort ? • Insertion Sort ? • Merge Sort ? • …. < 5, 3, 2, 1, 8, 6 > < 1, 2, 3, 5, 6, 8 >
  • 7. Performance Analysis of an algorithm • Performance of an algorithm is a process of making evaluative judgement about algorithms. • Performance of an algorithm means predicting the resources which are required to an algorithm to perform its task.
  • 8. Performance Analysis (cont.) • An algorithm is said to be efficient and fast, if it takes less time to execute and consumes less memory space. The performance of an algorithm is measured on the basis of following properties : • 1. Time Complexity • 2. Space Complexity
  • 9. Growth of some typical functions Functions of the form log k, n,cn,cn2 ,cn3 are called, respectively, logarithmic, linear, quadratic and cubic
  • 10. Three Asymptotic Notation • The O-notation , O(n2) (read “Oh of n2 ”or “big-Oh of n2 ”) • The Ω-notation, Ω(n) (read “omega of n”, or “big-omega of n”) • The Θ-notation , Θ(n2) (read “theta of n2 ”)
  • 11. The O-notation • In general, we say that the running time of an algorithm is O(g(n)), if whenever the input size is equal to or exceeds some threshold n0 , its running time can be bounded above by some positive constant c times g(n). • Definition: Let f(n) and g(n) be two functions from the set of natural numbers to the set of nonnegative real numbers. f(n) is said to be O(g(n)) if there exists a natural number n0 and a constant c > 0 such that ∀ n ≥ n0 , f(n) ≤ cg(n). Consequently, if lim 𝑛→∞ 𝑓(𝑛) 𝑔(𝑛) exists, then if lim 𝑛→∞ 𝑓(𝑛) 𝑔(𝑛) ≠ ∞ implies f(n) = O(g(n)).
  • 12. TIME COMPLEXITY • The time complexity of an algorithm is the total amount of time required by an algorithm to complete its execution. • If any program requires fixed amount of time for all input values then its time complexity is said to be Constant Time Complexity int sum(int a, int b) { return a+b; }
  • 13. SPACE COMPLEXITY • We define the space used by an algorithm to be the number of memory cells (or words) needed to carry out the computational steps required to solve an instance of the problem excluding the space allocated to hold the input. • All definitions of order of growth and asymptotic bounds pertaining to time complexity carry over to space complexity. It is clear that the work space cannot exceed the running time of an algorithm, as writing into each memory cell requires at least a constant amount of time.