SlideShare a Scribd company logo
INTRODUCTION TO ALGORITHM
Prepared by
R. Gomthijayam
Asst. Prof. of CA
Algorithms
• The word algorithm comes from the name of a Persian
mathematician Abu Ja’far Mohammed ibn-i Musa al
Khowarizmi.
• In computer science, this word refers to a special method
useable by a computer for solution of a problem. The
statement of the problem specifies in general terms the
desired input/output relationship.
• For example, sorting a given sequence of numbers into
nondecreasing order provides fertile ground for introducing
many standard design techniques and analysis tools.
The problem of sorting
Asymptotic Notation
The notation we use to describe the asymptotic running time
of an algorithm are defined in terms of functions whose
domains are the set of natural numbers
 ...,2,1,0N
O-notation
• For a given function , we denote by the set of
functions
• We use O-notation to give an asymptotic upper bound of a
function, to within a constant factor.
• means that there existes some constant c s.t.
is always for large enough n.
)(ng ))(( ngO








0
0
allfor)()(0
s.t.andconstantspositiveexistthere:)(
))((
nnncgnf
ncnf
ngO
))(()( ngOnf 
)(ncg)(nf
Ω-Omega notation
• For a given function , we denote by the set of
functions
• We use Ω-notation to give an asymptotic lower bound on a
function, to within a constant factor.
• means that there exists some constant c s.t.
is always for large enough n.
)(ng ))(( ng








0
0
allfor)()(0
s.t.andconstantspositiveexistthere:)(
))((
nnnfncg
ncnf
ng
))(()( ngnf 
)(nf )(ncg
-Theta notation
• For a given function , we denote by the set of
functions
• A function belongs to the set if there exist
positive constants and such that it can be “sand- wiched”
between and or sufficienly large n.
• means that there exists some constant c1 and c2
s.t. for large enough n.
)(ng ))(( ng








021
021
allfor)()()(c0
s.t.and,,constantspositiveexistthere:)(
))((
nnngcnfng
nccnf
ng
)(nf ))(( ng
1c 2c
)(1 ngc )(2 ngc
Θ
))(()( ngnf 
)()()( 21 ngcnfngc 
Standard notations and common functions
• Logarithms:
)lg(lglglg
)(loglog
logln
loglg 2
nn
nn
nn
nn
kk
e




Standard notations and common functions
• Factorials
For the Stirling approximation:



















ne
n
nn
n
1
12!
0n
)lg()!lg(
)2(!
)(!
nnn
n
non
n
n



Performance Measurement Needs
 programming language
 working program
 computer
 compiler and options to use
javac -o
Ad

More Related Content

What's hot (20)

Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
Mamta Pandey
 
Asymptotic Notation
Asymptotic NotationAsymptotic Notation
Asymptotic Notation
Lovely Professional University
 
Big o
Big oBig o
Big o
Thanhvinh Vo
 
Asymptotic Notation
Asymptotic NotationAsymptotic Notation
Asymptotic Notation
sohelranasweet
 
Asymptotic Notation and Complexity
Asymptotic Notation and ComplexityAsymptotic Notation and Complexity
Asymptotic Notation and Complexity
Rajandeep Gill
 
Asymptotic analysis
Asymptotic analysisAsymptotic analysis
Asymptotic analysis
Soujanya V
 
Asymptotic analysis
Asymptotic analysisAsymptotic analysis
Asymptotic analysis
Nisha Soms
 
Asymptotics 140510003721-phpapp02
Asymptotics 140510003721-phpapp02Asymptotics 140510003721-phpapp02
Asymptotics 140510003721-phpapp02
mansab MIRZA
 
Algorithm big o
Algorithm big oAlgorithm big o
Algorithm big o
Ashim Lamichhane
 
Asymptotic
AsymptoticAsymptotic
Asymptotic
Tuhin Utsab Paul
 
Complexity of Algorithm
Complexity of AlgorithmComplexity of Algorithm
Complexity of Algorithm
Muhammad Muzammal
 
Reconstruction
ReconstructionReconstruction
Reconstruction
COMSATS Abbottabad
 
Computational Complexity
Computational ComplexityComputational Complexity
Computational Complexity
Kasun Ranga Wijeweera
 
Algorithm.ppt
Algorithm.pptAlgorithm.ppt
Algorithm.ppt
Tareq Hasan
 
Lecture 4 asymptotic notations
Lecture 4   asymptotic notationsLecture 4   asymptotic notations
Lecture 4 asymptotic notations
jayavignesh86
 
Asymptotic notations(Big O, Omega, Theta )
Asymptotic notations(Big O, Omega, Theta )Asymptotic notations(Big O, Omega, Theta )
Asymptotic notations(Big O, Omega, Theta )
swapnac12
 
Algorithmic Notations
Algorithmic NotationsAlgorithmic Notations
Algorithmic Notations
Muhammad Muzammal
 
Complexity
ComplexityComplexity
Complexity
A. S. M. Shafi
 
Lecture 5: Asymptotic analysis of algorithms
Lecture 5: Asymptotic analysis of algorithmsLecture 5: Asymptotic analysis of algorithms
Lecture 5: Asymptotic analysis of algorithms
Vivek Bhargav
 
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
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
Mamta Pandey
 
Asymptotic Notation and Complexity
Asymptotic Notation and ComplexityAsymptotic Notation and Complexity
Asymptotic Notation and Complexity
Rajandeep Gill
 
Asymptotic analysis
Asymptotic analysisAsymptotic analysis
Asymptotic analysis
Soujanya V
 
Asymptotic analysis
Asymptotic analysisAsymptotic analysis
Asymptotic analysis
Nisha Soms
 
Asymptotics 140510003721-phpapp02
Asymptotics 140510003721-phpapp02Asymptotics 140510003721-phpapp02
Asymptotics 140510003721-phpapp02
mansab MIRZA
 
Lecture 4 asymptotic notations
Lecture 4   asymptotic notationsLecture 4   asymptotic notations
Lecture 4 asymptotic notations
jayavignesh86
 
Asymptotic notations(Big O, Omega, Theta )
Asymptotic notations(Big O, Omega, Theta )Asymptotic notations(Big O, Omega, Theta )
Asymptotic notations(Big O, Omega, Theta )
swapnac12
 
Lecture 5: Asymptotic analysis of algorithms
Lecture 5: Asymptotic analysis of algorithmsLecture 5: Asymptotic analysis of algorithms
Lecture 5: Asymptotic analysis of algorithms
Vivek Bhargav
 
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
 

Similar to Introducction to Algorithm (20)

Algorithm
AlgorithmAlgorithm
Algorithm
Syam Kumar
 
Algorithm
AlgorithmAlgorithm
Algorithm
Anirban Sarkar
 
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
 
Asymptotic Notations.pptx
Asymptotic Notations.pptxAsymptotic Notations.pptx
Asymptotic Notations.pptx
SunilWork1
 
algorithm_lec_1eregdsgdfgdgdfgdfgdfg.ppt
algorithm_lec_1eregdsgdfgdgdfgdfgdfg.pptalgorithm_lec_1eregdsgdfgdgdfgdfgdfg.ppt
algorithm_lec_1eregdsgdfgdgdfgdfgdfg.ppt
partho5958
 
Algorithm analysis and design
Algorithm analysis and designAlgorithm analysis and design
Algorithm analysis and design
Megha V
 
Asymptotic notations ada
Asymptotic notations adaAsymptotic notations ada
Asymptotic notations ada
ShaishavShah8
 
Asymptotic Notations
Asymptotic NotationsAsymptotic Notations
Asymptotic Notations
Rishabh Soni
 
Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1
Deepak John
 
Lec1
Lec1Lec1
Lec1
Nikhil Chilwant
 
Asymptotic Analysis.ppt
Asymptotic Analysis.pptAsymptotic Analysis.ppt
Asymptotic Analysis.ppt
abhishekchakraborty261420
 
Lec 2 algorithms efficiency complexity
Lec 2 algorithms efficiency  complexityLec 2 algorithms efficiency  complexity
Lec 2 algorithms efficiency complexity
Anaya Zafar
 
Intro to super. advance algorithm..pptx
Intro to super.   advance algorithm..pptxIntro to super.   advance algorithm..pptx
Intro to super. advance algorithm..pptx
ManishBaranwal10
 
DSA
DSADSA
DSA
rrupa2
 
Data Structures- Part2 analysis tools
Data Structures- Part2 analysis toolsData Structures- Part2 analysis tools
Data Structures- Part2 analysis tools
Abdullah Al-hazmy
 
Unit ii algorithm
Unit   ii algorithmUnit   ii algorithm
Unit ii algorithm
Tribhuvan University
 
complexity big oh notation notation.pptx
complexity big oh notation notation.pptxcomplexity big oh notation notation.pptx
complexity big oh notation notation.pptx
narifmsit18seecs
 
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
 
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
 
Asymptotic_Notations_v2_1709293258280.pptx
Asymptotic_Notations_v2_1709293258280.pptxAsymptotic_Notations_v2_1709293258280.pptx
Asymptotic_Notations_v2_1709293258280.pptx
prasanna220904
 
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
 
Asymptotic Notations.pptx
Asymptotic Notations.pptxAsymptotic Notations.pptx
Asymptotic Notations.pptx
SunilWork1
 
algorithm_lec_1eregdsgdfgdgdfgdfgdfg.ppt
algorithm_lec_1eregdsgdfgdgdfgdfgdfg.pptalgorithm_lec_1eregdsgdfgdgdfgdfgdfg.ppt
algorithm_lec_1eregdsgdfgdgdfgdfgdfg.ppt
partho5958
 
Algorithm analysis and design
Algorithm analysis and designAlgorithm analysis and design
Algorithm analysis and design
Megha V
 
Asymptotic notations ada
Asymptotic notations adaAsymptotic notations ada
Asymptotic notations ada
ShaishavShah8
 
Asymptotic Notations
Asymptotic NotationsAsymptotic Notations
Asymptotic Notations
Rishabh Soni
 
Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1
Deepak John
 
Lec 2 algorithms efficiency complexity
Lec 2 algorithms efficiency  complexityLec 2 algorithms efficiency  complexity
Lec 2 algorithms efficiency complexity
Anaya Zafar
 
Intro to super. advance algorithm..pptx
Intro to super.   advance algorithm..pptxIntro to super.   advance algorithm..pptx
Intro to super. advance algorithm..pptx
ManishBaranwal10
 
Data Structures- Part2 analysis tools
Data Structures- Part2 analysis toolsData Structures- Part2 analysis tools
Data Structures- Part2 analysis tools
Abdullah Al-hazmy
 
complexity big oh notation notation.pptx
complexity big oh notation notation.pptxcomplexity big oh notation notation.pptx
complexity big oh notation notation.pptx
narifmsit18seecs
 
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
 
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
 
Asymptotic_Notations_v2_1709293258280.pptx
Asymptotic_Notations_v2_1709293258280.pptxAsymptotic_Notations_v2_1709293258280.pptx
Asymptotic_Notations_v2_1709293258280.pptx
prasanna220904
 
Ad

More from Rajamanickam Gomathijayam (9)

Computer Application in Business
Computer Application in BusinessComputer Application in Business
Computer Application in Business
Rajamanickam Gomathijayam
 
Sololearn cert
Sololearn certSololearn cert
Sololearn cert
Rajamanickam Gomathijayam
 
Uml ppt
Uml pptUml ppt
Uml ppt
Rajamanickam Gomathijayam
 
Coding for php with mysql
Coding for php with mysqlCoding for php with mysql
Coding for php with mysql
Rajamanickam Gomathijayam
 
Php with mysql ppt
Php with mysql pptPhp with mysql ppt
Php with mysql ppt
Rajamanickam Gomathijayam
 
Corel Draw Introduction
Corel Draw IntroductionCorel Draw Introduction
Corel Draw Introduction
Rajamanickam Gomathijayam
 
Introduction to computer graphics
Introduction to computer graphicsIntroduction to computer graphics
Introduction to computer graphics
Rajamanickam Gomathijayam
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial Intelligence
Rajamanickam Gomathijayam
 
Network Concepts
Network ConceptsNetwork Concepts
Network Concepts
Rajamanickam Gomathijayam
 
Ad

Recently uploaded (20)

How to Create A Todo List In Todo of Odoo 18
How to Create A Todo List In Todo of Odoo 18How to Create A Todo List In Todo of Odoo 18
How to Create A Todo List In Todo of Odoo 18
Celine George
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
Link your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRMLink your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRM
Celine George
 
Junction Field Effect Transistors (JFET)
Junction Field Effect Transistors (JFET)Junction Field Effect Transistors (JFET)
Junction Field Effect Transistors (JFET)
GS Virdi
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdfBiophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
PKLI-Institute of Nursing and Allied Health Sciences Lahore , Pakistan.
 
All About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdfAll About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdf
TechSoup
 
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE  BY sweety Tamanna Mahapatra MSc PediatricAPGAR SCORE  BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
SweetytamannaMohapat
 
Ancient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian HistoryAncient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian History
Virag Sontakke
 
dynastic art of the Pallava dynasty south India
dynastic art of the Pallava dynasty south Indiadynastic art of the Pallava dynasty south India
dynastic art of the Pallava dynasty south India
PrachiSontakke5
 
03#UNTAGGED. Generosity in architecture.
03#UNTAGGED. Generosity in architecture.03#UNTAGGED. Generosity in architecture.
03#UNTAGGED. Generosity in architecture.
MCH
 
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Leonel Morgado
 
Rock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian HistoryRock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian History
Virag Sontakke
 
Cultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptxCultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptx
UmeshTimilsina1
 
Rococo versus Neoclassicism. The artistic styles of the 18th century
Rococo versus Neoclassicism. The artistic styles of the 18th centuryRococo versus Neoclassicism. The artistic styles of the 18th century
Rococo versus Neoclassicism. The artistic styles of the 18th century
Gema
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18
Celine George
 
Lecture 1 Introduction history and institutes of entomology_1.pptx
Lecture 1 Introduction history and institutes of entomology_1.pptxLecture 1 Introduction history and institutes of entomology_1.pptx
Lecture 1 Introduction history and institutes of entomology_1.pptx
Arshad Shaikh
 
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living WorkshopLDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDM Mia eStudios
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
How to Create A Todo List In Todo of Odoo 18
How to Create A Todo List In Todo of Odoo 18How to Create A Todo List In Todo of Odoo 18
How to Create A Todo List In Todo of Odoo 18
Celine George
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
Link your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRMLink your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRM
Celine George
 
Junction Field Effect Transistors (JFET)
Junction Field Effect Transistors (JFET)Junction Field Effect Transistors (JFET)
Junction Field Effect Transistors (JFET)
GS Virdi
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
All About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdfAll About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdf
TechSoup
 
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE  BY sweety Tamanna Mahapatra MSc PediatricAPGAR SCORE  BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
SweetytamannaMohapat
 
Ancient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian HistoryAncient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian History
Virag Sontakke
 
dynastic art of the Pallava dynasty south India
dynastic art of the Pallava dynasty south Indiadynastic art of the Pallava dynasty south India
dynastic art of the Pallava dynasty south India
PrachiSontakke5
 
03#UNTAGGED. Generosity in architecture.
03#UNTAGGED. Generosity in architecture.03#UNTAGGED. Generosity in architecture.
03#UNTAGGED. Generosity in architecture.
MCH
 
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Leonel Morgado
 
Rock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian HistoryRock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian History
Virag Sontakke
 
Cultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptxCultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptx
UmeshTimilsina1
 
Rococo versus Neoclassicism. The artistic styles of the 18th century
Rococo versus Neoclassicism. The artistic styles of the 18th centuryRococo versus Neoclassicism. The artistic styles of the 18th century
Rococo versus Neoclassicism. The artistic styles of the 18th century
Gema
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18
Celine George
 
Lecture 1 Introduction history and institutes of entomology_1.pptx
Lecture 1 Introduction history and institutes of entomology_1.pptxLecture 1 Introduction history and institutes of entomology_1.pptx
Lecture 1 Introduction history and institutes of entomology_1.pptx
Arshad Shaikh
 
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living WorkshopLDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDM Mia eStudios
 

Introducction to Algorithm

  • 1. INTRODUCTION TO ALGORITHM Prepared by R. Gomthijayam Asst. Prof. of CA
  • 2. Algorithms • The word algorithm comes from the name of a Persian mathematician Abu Ja’far Mohammed ibn-i Musa al Khowarizmi. • In computer science, this word refers to a special method useable by a computer for solution of a problem. The statement of the problem specifies in general terms the desired input/output relationship. • For example, sorting a given sequence of numbers into nondecreasing order provides fertile ground for introducing many standard design techniques and analysis tools.
  • 3. The problem of sorting
  • 4. Asymptotic Notation The notation we use to describe the asymptotic running time of an algorithm are defined in terms of functions whose domains are the set of natural numbers  ...,2,1,0N
  • 5. O-notation • For a given function , we denote by the set of functions • We use O-notation to give an asymptotic upper bound of a function, to within a constant factor. • means that there existes some constant c s.t. is always for large enough n. )(ng ))(( ngO         0 0 allfor)()(0 s.t.andconstantspositiveexistthere:)( ))(( nnncgnf ncnf ngO ))(()( ngOnf  )(ncg)(nf
  • 6. Ω-Omega notation • For a given function , we denote by the set of functions • We use Ω-notation to give an asymptotic lower bound on a function, to within a constant factor. • means that there exists some constant c s.t. is always for large enough n. )(ng ))(( ng         0 0 allfor)()(0 s.t.andconstantspositiveexistthere:)( ))(( nnnfncg ncnf ng ))(()( ngnf  )(nf )(ncg
  • 7. -Theta notation • For a given function , we denote by the set of functions • A function belongs to the set if there exist positive constants and such that it can be “sand- wiched” between and or sufficienly large n. • means that there exists some constant c1 and c2 s.t. for large enough n. )(ng ))(( ng         021 021 allfor)()()(c0 s.t.and,,constantspositiveexistthere:)( ))(( nnngcnfng nccnf ng )(nf ))(( ng 1c 2c )(1 ngc )(2 ngc Θ ))(()( ngnf  )()()( 21 ngcnfngc 
  • 8. Standard notations and common functions • Logarithms: )lg(lglglg )(loglog logln loglg 2 nn nn nn nn kk e    
  • 9. Standard notations and common functions • Factorials For the Stirling approximation:                    ne n nn n 1 12! 0n )lg()!lg( )2(! )(! nnn n non n n   
  • 10. Performance Measurement Needs  programming language  working program  computer  compiler and options to use javac -o