SlideShare a Scribd company logo
1
Algorithms
Informally Definition
An algorithm is any well-defined
computational procedure that
takes some values or set of
values as input and produces
some values or set of values as
output
Formal Definition
As a sequence of computational
steps that transforms the input
into output
4
Algorithms
Properties of algorithms:
• Input from a specified set,
• Output from a specified set (solution),
• Definiteness of every step in the computation,
• Correctness of output for every possible input,
• Finiteness of the number of calculation steps,
• Effectiveness of each calculation step and
• Generality for a class of problems.
?
Suppose computers were infinitely fast and
computer memory are free
Is there any reason to study algorithm ?
Yes
– Demonstrate that solution methods
terminates and does so with correct
answer.
If computers were infinitely fast,
any correct method for solving a
problem would do.
You would probably want your
implementation to be within the
bounds of good software
engineering practice
In reality
Computers may be fast, but they
are not infinitely fast and
Memory may be cheap but it is not
free
Computing time is therefore a
bounded resource and so is the
space in memory
8
Complexity
In general, we are not so much interested
in the time and space complexity for small
inputs.
For example, while the difference in time
complexity between linear and binary
search is meaningless for a sequence with n
= 10, it is gigantic for n = 230.
9
Complexity
For example, let us assume two algorithms A and
B that solve the same class of problems.
The time complexity of A is 5,000n, the one for
B is 1.1n for an input with n elements.
For n = 10, A requires 50,000 steps, but B only
3, so B seems to be superior to A.
For n = 1000, however, A requires 5,000,000
steps, while B requires 2.51041 steps.
10
Complexity
Comparison: time complexity of algorithms A and B
Algorithm A Algorithm BInput Size
n
10
100
1,000
1,000,000
5,000n
50,000
500,000
5,000,000
5109
1.1n
3
2.51041
13,781
4.81041392
11
Complexity
This means that algorithm B cannot be used for
large inputs, while algorithm A is still feasible.
So what is important is the growth of the
complexity functions.
The growth of time and space complexity with
increasing input size n is a suitable measure for
the comparison of algorithms.
Growth Function
The order of growth / rate of growth
of the running time of an algorithm
gives a simple characterization of the
algorithm efficiency and allow us to
compare the relative performance of
alternative algorithm
12
Asymptotic Efficiency
Algorithm
When the input size is large enough so
that the rate of growth / order of
growth of the running time is relevant
That is we are concerned with how the
running time of an algorithm
increases with the size of the input in
the limit, as the size of the input
increases without bound
13
Asymptotic Efficiency
Algorithm
Usually, an algorithm that is
asymptotically more efficient will
be the best choice for all but
very small inputs.
14
Asymptotic Notation
The notations 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 N = {0, 1,
2,…. }
15
Asymptotic Notation
Asymptotic notations are
convenient for describing the
worst-case running time function
T(n), which is defined only on
integer input size.
16
17
Asymptotic Notation
Let n be a non-negative integer
representing the size of the
input to an algorithm
18
Asymptotic Notation
Let f(n) and g(n) be two positive
functions, representing the
number of basic calculations
(operations, instructions) that an
algorithm takes (or the number
of memory words an algorithm
needs).
Asymptotic Notation
Q - Big Theta
O – Big O
W - Big Omega
o – Small o
w - Small Omega
19
Q - Notation
For a given function g(n), we denote
by Q(g(n)) the set of functions
Q(g(n)) = {f(n) : there exist positive
constants c1 , c2 , and n0 such
that 0  c1 g(n)  f(n)  c2 g(n)
for all n  n0
f(n)  Q(g(n)) f(n) = Q(g(n))
20
Q - Notation
21
g(n) is an
asymptotically tight
bound for f(n).
f(n) and g(n) are
nonnegative, for large
n.
Example
Q(g(n)) = {f(n) :  positive constants c1, c2,
and n0, such that n  n0, 0  c1g(n)
 f(n)  c2g(n) }
1/2n2 - 3n = Q(n2)
Determine the positive constant n0,
c1, and c2 such that
c1 n2  1/2n2 - 3n  c2 n2 n  n0
22
Example Contd ...
c1  1/2 – 3/n  c2 (Divide by n2)
c1 = 1/14 , c2 = ½ , n0 = 7
1/2n2 - 3n = Q(n2)
23
24
O-Notation
For a given function g(n)
O(g(n)) = {f(n) : there exist
positive constants c and n0 such
that 0  f(n)  c g(n) for all n 
n0 }
Intuitively: Set of all functions whose rate of
growth is the same as or lower than that of
c. g(n)
O-Notation
25
g(n) is an asymptotic upper bound for f(n).
f(n) = Q(g(n))  f(n) = O(g(n)).
Q(g(n))  O(g(n)).
Example
O(g(n)) = {f(n) : there exist positive
constants c and n0 such that 0  f(n) 
c g(n) for all n  n0 }
Any linear function an + b is in
O(n2). How?
C = a + |b| and n0 = 1
26
27
Big-O Notation
(Examples)
f(n) = 5n+2 = O(n) // g(n) = n
– f(n)  6n, for n  3 (C=6, n0=3)
f(n)=n/2 –3 = O(n)
– f(n)  0.5 n for n  0 (C=0.5, n0=0)
n2-n = O(n2) // g(n) = n2
– n2-n  n2 for n  0 (C=1, n0=0)
n(n+1)/2 = O(n2)
– n(n+1)/2  n2 for n  0 (C=1, n0=0)
W - Notation
For a given function g(n)
W(g(n)) = {f(n) : there exist
positive constants c and n0 such
that 0  c g(n)  f(n) for all
n  n0}
28
Intuitively: Set of all functions whose
rate of growth is the same as or higher
than that of g(n).
W - Notation
29
g(n) is an asymptotic lower bound for f(n).
f(n) = Q(g(n))  f(n) = W(g(n)).
Q(g(n))  W(g(n)).
Relations Between Q, O, W
30
Relations Between Q, O, W
For any two function f(n) and g(n),
we have f(n) = Q(g(n)) if and only
if f(n) = O(g(n)) and f(n) =
W(g(n))
That is
Q(g(n)) = O(g(n))  W(g(n))
31
32
The Growth of Functions
“Popular” functions g(n) are
n log n, 1, 2n, n2, n!, n, n3, log n
Listed from slowest to fastest growth:
• 1
• log n
• n
• n log n
• n2
• n3
• 2n
• n!
Comparing Growth Rates
Problem Size
T(n)
log2 n
n
n log2 n
n22n
Example: Find sum of array elements
Input size: n (number of array elements)
Total number of steps: 2n + 3
Algorithm arraySum (A, n)
Input array A of n integers
Output Sum of elements of A # operations
sum  0 1
for i  0 to n  1 do n+1
sum  sum + A [i] n
return sum 1
Algorithm arrayMax(A, n)
Input array A of n integers
Output maximum element of A # operations
currentMax  A[0] 1
for i  1 to n  1 do n
if A [i]  currentMax then n -1
currentMax  A [i] n -1
return currentMax 1
Example: Find max element of an
array
 Input size: n (number of array elements)
 Total number of steps: 3n

More Related Content

What's hot

Analysis of algorithm
Analysis of algorithmAnalysis of algorithm
Analysis of algorithm
Rajendra Dangwal
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithms
sandeep54552
 
Dijkstra s algorithm
Dijkstra s algorithmDijkstra s algorithm
Dijkstra s algorithm
mansab MIRZA
 
Graph traversals in Data Structures
Graph traversals in Data StructuresGraph traversals in Data Structures
Graph traversals in Data Structures
Anandhasilambarasan D
 
Algorithm analysis
Algorithm analysisAlgorithm analysis
Algorithm analysis
sumitbardhan
 
Pass by value and pass by reference
Pass by value and pass by reference Pass by value and pass by reference
Pass by value and pass by reference
TurnToTech
 
Algorithms Lecture 3: Analysis of Algorithms II
Algorithms Lecture 3: Analysis of Algorithms IIAlgorithms Lecture 3: Analysis of Algorithms II
Algorithms Lecture 3: Analysis of Algorithms II
Mohamed Loey
 
COMPILER DESIGN Run-Time Environments
COMPILER DESIGN Run-Time EnvironmentsCOMPILER DESIGN Run-Time Environments
Time complexity
Time complexityTime complexity
Time complexity
Katang Isip
 
Code generation in Compiler Design
Code generation in Compiler DesignCode generation in Compiler Design
Code generation in Compiler Design
Kuppusamy P
 
Complexity analysis in Algorithms
Complexity analysis in AlgorithmsComplexity analysis in Algorithms
Complexity analysis in Algorithms
Daffodil International University
 
Algorithm analysis (All in one)
Algorithm analysis (All in one)Algorithm analysis (All in one)
Algorithm analysis (All in one)
jehan1987
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
Akhil Kaushik
 
Top down parsering and bottom up parsering.pptx
Top down parsering and bottom up parsering.pptxTop down parsering and bottom up parsering.pptx
Top down parsering and bottom up parsering.pptx
LaibaFaisal3
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
Mohamed Loey
 
Data Structure and Algorithms.pptx
Data Structure and Algorithms.pptxData Structure and Algorithms.pptx
Data Structure and Algorithms.pptx
Syed Zaid Irshad
 
Intermediate code generation
Intermediate code generationIntermediate code generation
Intermediate code generation
Akshaya Arunan
 
Compiler Optimization Presentation
Compiler Optimization PresentationCompiler Optimization Presentation
Compiler Optimization Presentation
19magnet
 
Dag representation of basic blocks
Dag representation of basic blocksDag representation of basic blocks
Dag representation of basic blocks
Jothi Lakshmi
 
Dijkstra
DijkstraDijkstra
Dijkstra
jagdeeparora86
 

What's hot (20)

Analysis of algorithm
Analysis of algorithmAnalysis of algorithm
Analysis of algorithm
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithms
 
Dijkstra s algorithm
Dijkstra s algorithmDijkstra s algorithm
Dijkstra s algorithm
 
Graph traversals in Data Structures
Graph traversals in Data StructuresGraph traversals in Data Structures
Graph traversals in Data Structures
 
Algorithm analysis
Algorithm analysisAlgorithm analysis
Algorithm analysis
 
Pass by value and pass by reference
Pass by value and pass by reference Pass by value and pass by reference
Pass by value and pass by reference
 
Algorithms Lecture 3: Analysis of Algorithms II
Algorithms Lecture 3: Analysis of Algorithms IIAlgorithms Lecture 3: Analysis of Algorithms II
Algorithms Lecture 3: Analysis of Algorithms II
 
COMPILER DESIGN Run-Time Environments
COMPILER DESIGN Run-Time EnvironmentsCOMPILER DESIGN Run-Time Environments
COMPILER DESIGN Run-Time Environments
 
Time complexity
Time complexityTime complexity
Time complexity
 
Code generation in Compiler Design
Code generation in Compiler DesignCode generation in Compiler Design
Code generation in Compiler Design
 
Complexity analysis in Algorithms
Complexity analysis in AlgorithmsComplexity analysis in Algorithms
Complexity analysis in Algorithms
 
Algorithm analysis (All in one)
Algorithm analysis (All in one)Algorithm analysis (All in one)
Algorithm analysis (All in one)
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
 
Top down parsering and bottom up parsering.pptx
Top down parsering and bottom up parsering.pptxTop down parsering and bottom up parsering.pptx
Top down parsering and bottom up parsering.pptx
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
 
Data Structure and Algorithms.pptx
Data Structure and Algorithms.pptxData Structure and Algorithms.pptx
Data Structure and Algorithms.pptx
 
Intermediate code generation
Intermediate code generationIntermediate code generation
Intermediate code generation
 
Compiler Optimization Presentation
Compiler Optimization PresentationCompiler Optimization Presentation
Compiler Optimization Presentation
 
Dag representation of basic blocks
Dag representation of basic blocksDag representation of basic blocks
Dag representation of basic blocks
 
Dijkstra
DijkstraDijkstra
Dijkstra
 

Viewers also liked

8.binry search tree
8.binry search tree8.binry search tree
8.binry search tree
Chandan Singh
 
Introduction To Algorithm [2]
Introduction To Algorithm [2]Introduction To Algorithm [2]
Introduction To Algorithm [2]
ecko_disasterz
 
Algorithm analysis and efficiency
Algorithm analysis and efficiencyAlgorithm analysis and efficiency
Algorithm analysis and efficiency
ppts123456
 
Algorithm chapter 2
Algorithm chapter 2Algorithm chapter 2
Algorithm chapter 2
chidabdu
 
ADA complete notes
ADA complete notesADA complete notes
ADA complete notes
Vinay Kumar C
 
Time and space complexity
Time and space complexityTime and space complexity
Time and space complexity
Ankit Katiyar
 
17. Trees and Graphs
17. Trees and Graphs17. Trees and Graphs
17. Trees and Graphs
Intro C# Book
 

Viewers also liked (7)

8.binry search tree
8.binry search tree8.binry search tree
8.binry search tree
 
Introduction To Algorithm [2]
Introduction To Algorithm [2]Introduction To Algorithm [2]
Introduction To Algorithm [2]
 
Algorithm analysis and efficiency
Algorithm analysis and efficiencyAlgorithm analysis and efficiency
Algorithm analysis and efficiency
 
Algorithm chapter 2
Algorithm chapter 2Algorithm chapter 2
Algorithm chapter 2
 
ADA complete notes
ADA complete notesADA complete notes
ADA complete notes
 
Time and space complexity
Time and space complexityTime and space complexity
Time and space complexity
 
17. Trees and Graphs
17. Trees and Graphs17. Trees and Graphs
17. Trees and Graphs
 

Similar to 1.algorithms

Lecture 2 data structures and algorithms
Lecture 2 data structures and algorithmsLecture 2 data structures and algorithms
Lecture 2 data structures and algorithms
Aakash deep Singhal
 
Algorithms required for data structures(basics like Arrays, Stacks ,Linked Li...
Algorithms required for data structures(basics like Arrays, Stacks ,Linked Li...Algorithms required for data structures(basics like Arrays, Stacks ,Linked Li...
Algorithms required for data structures(basics like Arrays, Stacks ,Linked Li...
DebiPrasadSen
 
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
 
Asymptotic notation ada
Asymptotic notation adaAsymptotic notation ada
Asymptotic notation ada
ravinlaheri2
 
Algorithm Analysis
Algorithm AnalysisAlgorithm Analysis
Algorithm Analysis
Megha V
 
Time complexity.ppt
Time complexity.pptTime complexity.ppt
Time complexity.ppt
YekoyeTigabuYeko
 
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
Sajid Marwat
 
Asymptotic Notation and Complexity
Asymptotic Notation and ComplexityAsymptotic Notation and Complexity
Asymptotic Notation and Complexity
Rajandeep Gill
 
Asymptotic Notations.pptx
Asymptotic Notations.pptxAsymptotic Notations.pptx
Asymptotic Notations.pptx
SunilWork1
 
Lec03 04-time complexity
Lec03 04-time complexityLec03 04-time complexity
Lec03 04-time complexity
Abbas Ali
 
Asymptotics 140510003721-phpapp02
Asymptotics 140510003721-phpapp02Asymptotics 140510003721-phpapp02
Asymptotics 140510003721-phpapp02
mansab MIRZA
 
Design and analysis of algorithm ppt ppt
Design and analysis of algorithm ppt pptDesign and analysis of algorithm ppt ppt
Design and analysis of algorithm ppt ppt
srushtiivp
 
analysis.ppt
analysis.pptanalysis.ppt
analysis.ppt
AarushSharma69
 
Cs6402 daa-2 marks set 1
Cs6402 daa-2 marks set 1Cs6402 daa-2 marks set 1
Cs6402 daa-2 marks set 1
Vai Jayanthi
 
lecture 1
lecture 1lecture 1
lecture 1
sajinsc
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
sajinis3
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
Saranya Natarajan
 
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/ThetaAlgorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta
Priyanka Rana
 
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
 
Lecture 3(a) Asymptotic-analysis.pdf
Lecture 3(a) Asymptotic-analysis.pdfLecture 3(a) Asymptotic-analysis.pdf
Lecture 3(a) Asymptotic-analysis.pdf
ShaistaRiaz4
 

Similar to 1.algorithms (20)

Lecture 2 data structures and algorithms
Lecture 2 data structures and algorithmsLecture 2 data structures and algorithms
Lecture 2 data structures and algorithms
 
Algorithms required for data structures(basics like Arrays, Stacks ,Linked Li...
Algorithms required for data structures(basics like Arrays, Stacks ,Linked Li...Algorithms required for data structures(basics like Arrays, Stacks ,Linked Li...
Algorithms required for data structures(basics like Arrays, Stacks ,Linked Li...
 
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
 
Asymptotic notation ada
Asymptotic notation adaAsymptotic notation ada
Asymptotic notation ada
 
Algorithm Analysis
Algorithm AnalysisAlgorithm Analysis
Algorithm Analysis
 
Time complexity.ppt
Time complexity.pptTime complexity.ppt
Time complexity.ppt
 
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
 
Asymptotic Notation and Complexity
Asymptotic Notation and ComplexityAsymptotic Notation and Complexity
Asymptotic Notation and Complexity
 
Asymptotic Notations.pptx
Asymptotic Notations.pptxAsymptotic Notations.pptx
Asymptotic Notations.pptx
 
Lec03 04-time complexity
Lec03 04-time complexityLec03 04-time complexity
Lec03 04-time complexity
 
Asymptotics 140510003721-phpapp02
Asymptotics 140510003721-phpapp02Asymptotics 140510003721-phpapp02
Asymptotics 140510003721-phpapp02
 
Design and analysis of algorithm ppt ppt
Design and analysis of algorithm ppt pptDesign and analysis of algorithm ppt ppt
Design and analysis of algorithm ppt ppt
 
analysis.ppt
analysis.pptanalysis.ppt
analysis.ppt
 
Cs6402 daa-2 marks set 1
Cs6402 daa-2 marks set 1Cs6402 daa-2 marks set 1
Cs6402 daa-2 marks set 1
 
lecture 1
lecture 1lecture 1
lecture 1
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
 
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/ThetaAlgorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta
 
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.
 
Lecture 3(a) Asymptotic-analysis.pdf
Lecture 3(a) Asymptotic-analysis.pdfLecture 3(a) Asymptotic-analysis.pdf
Lecture 3(a) Asymptotic-analysis.pdf
 

More from Chandan Singh

Fundamental of Tissue engineering
Fundamental of Tissue engineeringFundamental of Tissue engineering
Fundamental of Tissue engineering
Chandan Singh
 
Resistance Measurement instruments
Resistance Measurement instrumentsResistance Measurement instruments
Resistance Measurement instruments
Chandan Singh
 
Resistance Measurement instruments
Resistance Measurement instrumentsResistance Measurement instruments
Resistance Measurement instruments
Chandan Singh
 
Moving iron (MI) instruments
Moving iron (MI) instrumentsMoving iron (MI) instruments
Moving iron (MI) instruments
Chandan Singh
 
Moving iron (MI) instruments
Moving iron (MI) instrumentsMoving iron (MI) instruments
Moving iron (MI) instruments
Chandan Singh
 
Electrical Measurement & Instruments
Electrical Measurement & InstrumentsElectrical Measurement & Instruments
Electrical Measurement & Instruments
Chandan Singh
 
Static characteristics of Instruments
Static characteristics of InstrumentsStatic characteristics of Instruments
Static characteristics of Instruments
Chandan Singh
 
Resistance measurement
Resistance measurementResistance measurement
Resistance measurement
Chandan Singh
 
Introduction to sensors
Introduction to sensorsIntroduction to sensors
Introduction to sensors
Chandan Singh
 
Energy meter
Energy meterEnergy meter
Energy meter
Chandan Singh
 
Classification (Analog instruments)
 Classification (Analog instruments) Classification (Analog instruments)
Classification (Analog instruments)
Chandan Singh
 
AC Bridges: Balance Condition
AC Bridges: Balance ConditionAC Bridges: Balance Condition
AC Bridges: Balance Condition
Chandan Singh
 
Cathode Ray Osciloscope
Cathode Ray OsciloscopeCathode Ray Osciloscope
Cathode Ray Osciloscope
Chandan Singh
 
Instrument transformer CT & PT
Instrument transformer CT & PTInstrument transformer CT & PT
Instrument transformer CT & PT
Chandan Singh
 
Megohmmeter
MegohmmeterMegohmmeter
Megohmmeter
Chandan Singh
 
Moving Iron
Moving IronMoving Iron
Moving Iron
Chandan Singh
 
Permanent Magnet Moving Coil
Permanent Magnet Moving Coil Permanent Magnet Moving Coil
Permanent Magnet Moving Coil
Chandan Singh
 
10.m way search tree
10.m way search tree10.m way search tree
10.m way search tree
Chandan Singh
 
9.bst(contd.) avl tree
9.bst(contd.) avl tree9.bst(contd.) avl tree
9.bst(contd.) avl tree
Chandan Singh
 
7.tree
7.tree7.tree

More from Chandan Singh (20)

Fundamental of Tissue engineering
Fundamental of Tissue engineeringFundamental of Tissue engineering
Fundamental of Tissue engineering
 
Resistance Measurement instruments
Resistance Measurement instrumentsResistance Measurement instruments
Resistance Measurement instruments
 
Resistance Measurement instruments
Resistance Measurement instrumentsResistance Measurement instruments
Resistance Measurement instruments
 
Moving iron (MI) instruments
Moving iron (MI) instrumentsMoving iron (MI) instruments
Moving iron (MI) instruments
 
Moving iron (MI) instruments
Moving iron (MI) instrumentsMoving iron (MI) instruments
Moving iron (MI) instruments
 
Electrical Measurement & Instruments
Electrical Measurement & InstrumentsElectrical Measurement & Instruments
Electrical Measurement & Instruments
 
Static characteristics of Instruments
Static characteristics of InstrumentsStatic characteristics of Instruments
Static characteristics of Instruments
 
Resistance measurement
Resistance measurementResistance measurement
Resistance measurement
 
Introduction to sensors
Introduction to sensorsIntroduction to sensors
Introduction to sensors
 
Energy meter
Energy meterEnergy meter
Energy meter
 
Classification (Analog instruments)
 Classification (Analog instruments) Classification (Analog instruments)
Classification (Analog instruments)
 
AC Bridges: Balance Condition
AC Bridges: Balance ConditionAC Bridges: Balance Condition
AC Bridges: Balance Condition
 
Cathode Ray Osciloscope
Cathode Ray OsciloscopeCathode Ray Osciloscope
Cathode Ray Osciloscope
 
Instrument transformer CT & PT
Instrument transformer CT & PTInstrument transformer CT & PT
Instrument transformer CT & PT
 
Megohmmeter
MegohmmeterMegohmmeter
Megohmmeter
 
Moving Iron
Moving IronMoving Iron
Moving Iron
 
Permanent Magnet Moving Coil
Permanent Magnet Moving Coil Permanent Magnet Moving Coil
Permanent Magnet Moving Coil
 
10.m way search tree
10.m way search tree10.m way search tree
10.m way search tree
 
9.bst(contd.) avl tree
9.bst(contd.) avl tree9.bst(contd.) avl tree
9.bst(contd.) avl tree
 
7.tree
7.tree7.tree
7.tree
 

Recently uploaded

Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
Madan Karki
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
Mukeshwaran Balu
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
University of Maribor
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
IJNSA Journal
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
gerogepatton
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
camseq
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
ihlasbinance2003
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
SyedAbiiAzazi1
 
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
JamalHussainArman
 
Question paper of renewable energy sources
Question paper of renewable energy sourcesQuestion paper of renewable energy sources
Question paper of renewable energy sources
mahammadsalmanmech
 
2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt
PuktoonEngr
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
VICTOR MAESTRE RAMIREZ
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
kandramariana6
 
New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
wisnuprabawa3
 
Heat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation pptHeat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation ppt
mamunhossenbd75
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
anoopmanoharan2
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
nooriasukmaningtyas
 

Recently uploaded (20)

Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
 
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
 
Question paper of renewable energy sources
Question paper of renewable energy sourcesQuestion paper of renewable energy sources
Question paper of renewable energy sources
 
2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
 
New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
 
Heat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation pptHeat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation ppt
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
 

1.algorithms

  • 2. Informally Definition An algorithm is any well-defined computational procedure that takes some values or set of values as input and produces some values or set of values as output
  • 3. Formal Definition As a sequence of computational steps that transforms the input into output
  • 4. 4 Algorithms Properties of algorithms: • Input from a specified set, • Output from a specified set (solution), • Definiteness of every step in the computation, • Correctness of output for every possible input, • Finiteness of the number of calculation steps, • Effectiveness of each calculation step and • Generality for a class of problems.
  • 5. ? Suppose computers were infinitely fast and computer memory are free Is there any reason to study algorithm ? Yes – Demonstrate that solution methods terminates and does so with correct answer.
  • 6. If computers were infinitely fast, any correct method for solving a problem would do. You would probably want your implementation to be within the bounds of good software engineering practice
  • 7. In reality Computers may be fast, but they are not infinitely fast and Memory may be cheap but it is not free Computing time is therefore a bounded resource and so is the space in memory
  • 8. 8 Complexity In general, we are not so much interested in the time and space complexity for small inputs. For example, while the difference in time complexity between linear and binary search is meaningless for a sequence with n = 10, it is gigantic for n = 230.
  • 9. 9 Complexity For example, let us assume two algorithms A and B that solve the same class of problems. The time complexity of A is 5,000n, the one for B is 1.1n for an input with n elements. For n = 10, A requires 50,000 steps, but B only 3, so B seems to be superior to A. For n = 1000, however, A requires 5,000,000 steps, while B requires 2.51041 steps.
  • 10. 10 Complexity Comparison: time complexity of algorithms A and B Algorithm A Algorithm BInput Size n 10 100 1,000 1,000,000 5,000n 50,000 500,000 5,000,000 5109 1.1n 3 2.51041 13,781 4.81041392
  • 11. 11 Complexity This means that algorithm B cannot be used for large inputs, while algorithm A is still feasible. So what is important is the growth of the complexity functions. The growth of time and space complexity with increasing input size n is a suitable measure for the comparison of algorithms.
  • 12. Growth Function The order of growth / rate of growth of the running time of an algorithm gives a simple characterization of the algorithm efficiency and allow us to compare the relative performance of alternative algorithm 12
  • 13. Asymptotic Efficiency Algorithm When the input size is large enough so that the rate of growth / order of growth of the running time is relevant That is we are concerned with how the running time of an algorithm increases with the size of the input in the limit, as the size of the input increases without bound 13
  • 14. Asymptotic Efficiency Algorithm Usually, an algorithm that is asymptotically more efficient will be the best choice for all but very small inputs. 14
  • 15. Asymptotic Notation The notations 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 N = {0, 1, 2,…. } 15
  • 16. Asymptotic Notation Asymptotic notations are convenient for describing the worst-case running time function T(n), which is defined only on integer input size. 16
  • 17. 17 Asymptotic Notation Let n be a non-negative integer representing the size of the input to an algorithm
  • 18. 18 Asymptotic Notation Let f(n) and g(n) be two positive functions, representing the number of basic calculations (operations, instructions) that an algorithm takes (or the number of memory words an algorithm needs).
  • 19. Asymptotic Notation Q - Big Theta O – Big O W - Big Omega o – Small o w - Small Omega 19
  • 20. Q - Notation For a given function g(n), we denote by Q(g(n)) the set of functions Q(g(n)) = {f(n) : there exist positive constants c1 , c2 , and n0 such that 0  c1 g(n)  f(n)  c2 g(n) for all n  n0 f(n)  Q(g(n)) f(n) = Q(g(n)) 20
  • 21. Q - Notation 21 g(n) is an asymptotically tight bound for f(n). f(n) and g(n) are nonnegative, for large n.
  • 22. Example Q(g(n)) = {f(n) :  positive constants c1, c2, and n0, such that n  n0, 0  c1g(n)  f(n)  c2g(n) } 1/2n2 - 3n = Q(n2) Determine the positive constant n0, c1, and c2 such that c1 n2  1/2n2 - 3n  c2 n2 n  n0 22
  • 23. Example Contd ... c1  1/2 – 3/n  c2 (Divide by n2) c1 = 1/14 , c2 = ½ , n0 = 7 1/2n2 - 3n = Q(n2) 23
  • 24. 24 O-Notation For a given function g(n) O(g(n)) = {f(n) : there exist positive constants c and n0 such that 0  f(n)  c g(n) for all n  n0 } Intuitively: Set of all functions whose rate of growth is the same as or lower than that of c. g(n)
  • 25. O-Notation 25 g(n) is an asymptotic upper bound for f(n). f(n) = Q(g(n))  f(n) = O(g(n)). Q(g(n))  O(g(n)).
  • 26. Example O(g(n)) = {f(n) : there exist positive constants c and n0 such that 0  f(n)  c g(n) for all n  n0 } Any linear function an + b is in O(n2). How? C = a + |b| and n0 = 1 26
  • 27. 27 Big-O Notation (Examples) f(n) = 5n+2 = O(n) // g(n) = n – f(n)  6n, for n  3 (C=6, n0=3) f(n)=n/2 –3 = O(n) – f(n)  0.5 n for n  0 (C=0.5, n0=0) n2-n = O(n2) // g(n) = n2 – n2-n  n2 for n  0 (C=1, n0=0) n(n+1)/2 = O(n2) – n(n+1)/2  n2 for n  0 (C=1, n0=0)
  • 28. W - Notation For a given function g(n) W(g(n)) = {f(n) : there exist positive constants c and n0 such that 0  c g(n)  f(n) for all n  n0} 28 Intuitively: Set of all functions whose rate of growth is the same as or higher than that of g(n).
  • 29. W - Notation 29 g(n) is an asymptotic lower bound for f(n). f(n) = Q(g(n))  f(n) = W(g(n)). Q(g(n))  W(g(n)).
  • 31. Relations Between Q, O, W For any two function f(n) and g(n), we have f(n) = Q(g(n)) if and only if f(n) = O(g(n)) and f(n) = W(g(n)) That is Q(g(n)) = O(g(n))  W(g(n)) 31
  • 32. 32 The Growth of Functions “Popular” functions g(n) are n log n, 1, 2n, n2, n!, n, n3, log n Listed from slowest to fastest growth: • 1 • log n • n • n log n • n2 • n3 • 2n • n!
  • 33. Comparing Growth Rates Problem Size T(n) log2 n n n log2 n n22n
  • 34. Example: Find sum of array elements Input size: n (number of array elements) Total number of steps: 2n + 3 Algorithm arraySum (A, n) Input array A of n integers Output Sum of elements of A # operations sum  0 1 for i  0 to n  1 do n+1 sum  sum + A [i] n return sum 1
  • 35. Algorithm arrayMax(A, n) Input array A of n integers Output maximum element of A # operations currentMax  A[0] 1 for i  1 to n  1 do n if A [i]  currentMax then n -1 currentMax  A [i] n -1 return currentMax 1 Example: Find max element of an array  Input size: n (number of array elements)  Total number of steps: 3n