SlideShare une entreprise Scribd logo
1  sur  24
Télécharger pour lire hors ligne
ALGORITHM CLASSS
Algorithm Analysis
DS C C++ JAVA TRAINING INSTITUTES IN KPHB HYDERABAD
Program=instructions + data
Description of algorithms and data structures to achieve a specific objective
Could be done in any language, even a natural language like Wnglish
Example add a and b
Read a ; read b; c=a+b; // Algorithm
A , b and c are data structures
Programming language: A standard notation for writing programs
Like english or telugu
Examples: C, Java, intel assemly language, machine language etc
Hardware understands machine language but we instructs using programming language.
Hence we need the program translators like compiler gcc
C++ TRAINING INSTITUTES IN KPHB HYDERABAD
What is a computer program
ALGORITHM CLASSS
ALGORITHM CLASSS
If you are strong with data structures, you can
 evaluate the quality of a program
(Analysis of Algorithms: Running time and memory space )
 write fast,efficient and quality programs with less memory usage
 solve new problems efficiently by choosing appropriate data structures and
algorithms
C++ TRAINING INSTITUTES IN KPHB HYDERABAD
Why do we need this course
ALGORITHM CLASSS
 How smart you are to pick the appropriate data structure for a given problem(if you
know pros and cons of different DS only you can decide)
 How strong you are on programming basics (DS)
 Ability to decompose problems
 Ability to find solutions with a better logic
 Efficient programming skills
… etc.
DS TRAINING INSTITUTES IN KPHB HYDERABAD
Why interviewer concentrates more on DS
ALGORITHM CLASSS
Data Structures:
A systematic way of organizing and accessing data
.
--No single data structure works well for ALL purposes.
Algorithm
is a step-by-step procedure for solving a problem in a finite amount of time.
Algorithm analysis
a process of determining the amount of time, resource, etc. required when executing an
algorithm
Estimate the running time
Estimate the memory space required.
Depends on the input size
DS TRAINING INSTITUTES IN KPHB HYDERABAD
What is an algorithm analysis
ALGORITHM CLASSS
There are two aspects of algorithmic performance:
Time
Instructions take time.
How fast does the algorithm perform?
What affects its runtime?
Space
Data structures take space
What kind of data structures can be used?
How does choice of data structure affect the runtime?
We will focus on time:
How to estimate the time required for an algorithm
How to reduce the time required
Analysis of Algorithms
is the area of computer science that provides tools to analyze the efficiency of different methods of
solutions.
How do we compare the time efficiency of two algorithms that solve the same problem?
Naïve Approach: implement these algorithms in a programming language (C++), and run them to
compare their time requirements. Comparing the programs (instead of algorithms) has difficulties.
JAVA TRAINING INSTITUTES IN KPHB HYDERABAD
What is an algorithm analysis
ALGORITHM CLASSS
To analyze algorithms:
First, we start to count the number of significant operations in a particular solution to assess its
efficiency.
Then, we will express the efficiency of algorithms using growth functions.
Growth Rate
We measure an algorithm’s time requirement as a function of the problem size.
Problem size depends on the application: e.g. number of elements in a list for a sorting
algorithm, the number disks for towers of hanoi.
So, for instance, we say that (if the problem size is n)
Algorithm A requires 5*n2 time units to solve a problem of size n.
Algorithm B requires 7*n time units to solve a problem of size n.
The most important thing to learn is how quickly the algorithm’s time requirement grows as a
function of the problem size.
Algorithm A requires time proportional to n2.
Algorithm B requires time proportional to n.
An algorithm’s proportional time requirement is known as growth rate. We can compare the
efficiency of two algorithms by comparing their growth rates.
C TRAINING INSTITUTES IN KPHB HYDERABAD
What is an algorithm analysis
ALGORITHM CLASSS
What is an algorithm analysis
Function Growth Rate Name
c Constant
log N Logarithmic
log2N Log-squared
N Linear
N log N
N2 Quadratic
N3 Cubic
2N Exponential
ALGORITHM CLASSS
Experimental Studies
Write a program implementing the algorithm
Run the program with inputs of varying size and composition
Use a method like System.currentTimeMillis() to get an accurate measure of the actual
running time
Plot the results and compare
Limitations of the experiments
It is necessary to implement the algorithm, which may be difficult
Results may not be indicative of the running time on other inputs not included in the
experiment.
In order to compare two algorithms, the same hardware and software environments must
be used
JAVA TRAINING INSTITUTES IN KPHB HYDERABAD
What is an algorithm analysis
ALGORITHM CLASSS
Theoretical Analysis
Uses a high-level description of the algorithm instead of an implementation
Characterizes running time as a function of the input size, n.
Takes into account all possible inputs
Allows us to evaluate the speed of an algorithm independent of the hardware/software
environment
Asymptotic Algorithm Analysis
The asymptotic analysis of an algorithm determines the running time in big-Oh notation
To perform the asymptotic analysis
We find the worst-case number of primitive operations executed as a function of the
input size
We express this function with big-Oh notation
What is an algorithm analysis
(Big-Oh)
T(n) is O(F(n)) if there are positive constants c and n0 such that
T(n)<= cF(n) when n >= n0
Provides an upper bound on the growth rate of the function.
(Big-Omega)
T(n) is Ω(F(n)) if there are positive constant c and n0 such that
T(n) >= cF(n) when n >= n0
we want to say that an algorithm takes at least a certain amount of time,
Def: (Big-Theta) T(n) is Θ(F(n)) if and only if
T(n) = O(F(n)) and T(n) = Ω(F(n)) => k1*F(n) <
Def: (Little-Oh) T(n) = o(F(n)) if and only if
T(n) = O(F(n)) and T(n) != Θ (F(n))
we cannot say here what the value of c_1c​1​​ is, because it depends on the speed of the
computer, the programming language used, the compiler or interpreter that translates the
source program into runnable code, and other factors.
C++ TRAINING INSTITUTES IN KPHB HYDERABAD
Algorithm analysis: other notations
ALGORITHM CLASSS
Asymptotic Algorithm Analysis
The asymptotic analysis of an algorithm determines the running time in big-Oh notation
To perform the asymptotic analysis
We find the worst-case number of primitive operations executed as a function of
the input size
We express this function with big-Oh notation
Example:
We determine that algorithm arrayMax executes at most 6n  1 primitive
operations
We say that algorithm arrayMax “runs in O(n) time”
Since constant factors and lower-order terms are eventually dropped anyhow, we
can disregard them when counting primitive operations
Algorithm analysis: BIG-Oh notation
ALGORITHM CLASSS
Big O notation:
Big Oh notation is used to capture the most dominant term in a function, and to represent
the growth rate.
Also called asymptotic upper bound.
Ex: 100n3 + 30000n =>O(n3)
To simplify the running time estimation, for a function f(n), we ignore the constants and
lower order terms.
Example: 10n3+4n2-4n+5 is O(n3).
http://sites.google.com/site/algorithmclass
BIG-Oh notation
http://sites.google.com/site/algorithmclass
BIG-Oh notation
http://sites.google.com/site/algorithmclass
Theta
Definition: A theoretical measure of the execution of an algorithm, usually the time
or memory needed, given the problem size n, which is usually the number of items.
Informally, saying some equation f(n) = Θ (g(n)) means it is within a constant multiple
of g(n). The equation is read, "f of n is theta g of n".
Formal Definition: f(n) = Θ (g(n)) means there are positive constants c1, c2, and k,
such that 0 ≤ c1g(n) ≤ f(n) ≤ c2g(n) for all n ≥ k. The values of c1, c2, and k must be f
ixed for the function f and must not depend on n.
http://plus.google.com/+AlgorithmClass
Omege
(Big-Omega)
T(n) is Ω(F(n)) if there are positive constant c and n0 such that
T(n) >= cF(n) when n >= n0
we want to say that an algorithm takes at least a certain amount of time,
https://plus.google.com/+AlgorithmClass
BIG-Oh notation
Definition: A theoretical measure of the execution of an algorithm, usually the time or
memory needed, given the problem size n, which is usually the number of items. Informally,
saying some equation f(n) = O(g(n)) means it is less than some constant multiple of g(n).
The notation is read, "f of n is big oh of g of n".
Formal Definition: f(n) = O(g(n)) means there are positive constants c and k, such that 0 ≤
f(n) ≤ cg(n) for all n ≥ k. The values of c and k must be fixed for the function f and must not
depend on n.
ALGORITHM CLASSS
Primitive Operations
Basic computations performed by an algorithm
Largely independent from the programming language
Examples:
Evaluating an expression
Assigning a value to a variable
Indexing into an array
Calling a method
Returning from a method
Algorithm analysis: BIG-Oh notation
Algorithm arrayMax(A, n)
currentMax=a[0]; // 2
for (i=1;i<n;i++) // 2n //(i=1 once, i<n n
times, i++ (n-1) times)
if (a[i] > currentMax) 2(n-1)
currentMax=a[i] 2(n-1)
return currentMax; 1
total time= 6n-1
Function Name
C Constant
LogN Logarithmic
Log2N Log-squared
N Linear
NlogN NlogN
N2 Quaratic
N3 Cubic
2n Exponential
Algorithm analysis: BIG-Oh notation
Algorithm analysis: BIG-Oh notation
Algorithm analysis: BIG-Oh notation
Worst-case vs. Average-case
A worst-case bound is a guarantee over all inputs of size N.
In an average-case bound, the running time is measured as an average over all of the
possible inputs of size N.
We will mainly focus on worst-case analysis, but sometimes it is useful to do average
one.
Example:
Static Searching Problem
Given an integer X and an array A, return the position of X in A or an indication that it
is not present. If X occurs more than once, return any occurrence. The array A is never
altered.
Sequential search: =>O(n)
Binary search (sorted data): => O(logn)
BIG-Oh notation
Sequential search
A sequential search steps through the data sequentially until an match is found.
A sequential search is useful when the array is not sorted.
A sequential search is linear O(n) (i.e. proportional to the size of input)
 Unsuccessful search --- n times
 Successful search (worst) --- n times
 Successful search (average) --- n/2 times
Binary Search
If the array has been sorted, we can use binary search, which is performed from
the middle of the array rather than the end.
We keep track of low_end and high_end, which delimit the portion of the array in
which an item, if present, must reside.
If low_end is larger than high_end, we know the item is not present.
Algorithm analysis: Example
Algorithm Class
Email: algorithm.class@gmail.com
Website: http://sites.google.com/site/algorithmclass
G+ : http://plus.google.com/+AlgorithmClass/posts
Facebook : http://www.facebook.com/AlgorithmClassCCppDsJavaTrainingKphbHyderabad
ALGORITHM CLASSS
C C++ DS Data Structures CPP JAVA TRAINING INSTITUTE KPHB HYDERABAD
/

Contenu connexe

Tendances

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
 
Basic Computer Engineering Unit II as per RGPV Syllabus
Basic Computer Engineering Unit II as per RGPV SyllabusBasic Computer Engineering Unit II as per RGPV Syllabus
Basic Computer Engineering Unit II as per RGPV SyllabusNANDINI SHARMA
 
Algorithm Analysis
Algorithm AnalysisAlgorithm Analysis
Algorithm AnalysisMegha V
 
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
 
Basic terminologies & asymptotic notations
Basic terminologies & asymptotic notationsBasic terminologies & asymptotic notations
Basic terminologies & asymptotic notationsRajendran
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)swapnac12
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsMohamed Loey
 
Lecture 3 insertion sort and complexity analysis
Lecture 3   insertion sort and complexity analysisLecture 3   insertion sort and complexity analysis
Lecture 3 insertion sort and complexity analysisjayavignesh86
 
Introduction to Algorithms and Asymptotic Notation
Introduction to Algorithms and Asymptotic NotationIntroduction to Algorithms and Asymptotic Notation
Introduction to Algorithms and Asymptotic NotationAmrinder Arora
 
Time and space complexity
Time and space complexityTime and space complexity
Time and space complexityAnkit Katiyar
 
Asymptotic Analysis
Asymptotic AnalysisAsymptotic Analysis
Asymptotic Analysissonugupta
 

Tendances (16)

Complexity of Algorithm
Complexity of AlgorithmComplexity of Algorithm
Complexity of Algorithm
 
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
 
Basic Computer Engineering Unit II as per RGPV Syllabus
Basic Computer Engineering Unit II as per RGPV SyllabusBasic Computer Engineering Unit II as per RGPV Syllabus
Basic Computer Engineering Unit II as per RGPV Syllabus
 
Algorithm Analysis
Algorithm AnalysisAlgorithm Analysis
Algorithm Analysis
 
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
 
Basic terminologies & asymptotic notations
Basic terminologies & asymptotic notationsBasic terminologies & asymptotic notations
Basic terminologies & asymptotic notations
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
 
Cis435 week01
Cis435 week01Cis435 week01
Cis435 week01
 
Big o
Big oBig o
Big o
 
asymptotic notation
asymptotic notationasymptotic notation
asymptotic notation
 
Lecture 3 insertion sort and complexity analysis
Lecture 3   insertion sort and complexity analysisLecture 3   insertion sort and complexity analysis
Lecture 3 insertion sort and complexity analysis
 
Introduction to Algorithms and Asymptotic Notation
Introduction to Algorithms and Asymptotic NotationIntroduction to Algorithms and Asymptotic Notation
Introduction to Algorithms and Asymptotic Notation
 
Time and space complexity
Time and space complexityTime and space complexity
Time and space complexity
 
Asymptotic Analysis
Asymptotic AnalysisAsymptotic Analysis
Asymptotic Analysis
 

En vedette

En vedette (9)

Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
 
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
 
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
 
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
 
Algorithm Class at KPHB (C, C++ Course Training Institute in KPHB, Kukatpally...
Algorithm Class at KPHB (C, C++ Course Training Institute in KPHB, Kukatpally...Algorithm Class at KPHB (C, C++ Course Training Institute in KPHB, Kukatpally...
Algorithm Class at KPHB (C, C++ Course Training Institute in KPHB, Kukatpally...
 
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
 
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
 
Algorithm Class is a Training Institute on C, C++, CPP, DS, JAVA, data struct...
Algorithm Class is a Training Institute on C, C++, CPP, DS, JAVA, data struct...Algorithm Class is a Training Institute on C, C++, CPP, DS, JAVA, data struct...
Algorithm Class is a Training Institute on C, C++, CPP, DS, JAVA, data struct...
 
Algorithm Class at KPHB C, CPP Training Institutes in KPHB, Kukatpally,Hyde...
Algorithm Class at KPHB C,  CPP Training Institutes in  KPHB, Kukatpally,Hyde...Algorithm Class at KPHB C,  CPP Training Institutes in  KPHB, Kukatpally,Hyde...
Algorithm Class at KPHB C, CPP Training Institutes in KPHB, Kukatpally,Hyde...
 

Similaire à Algorithm Class at KPHB (C, C++ Course Training Institute in KPHB, Kukatpally KPHB, Hyderabad.)

Data Structures and Algorithms Lecture 2: Analysis of Algorithms, Asymptotic ...
Data Structures and Algorithms Lecture 2: Analysis of Algorithms, Asymptotic ...Data Structures and Algorithms Lecture 2: Analysis of Algorithms, Asymptotic ...
Data Structures and Algorithms Lecture 2: Analysis of Algorithms, Asymptotic ...TechVision8
 
Data Structures- Part2 analysis tools
Data Structures- Part2 analysis toolsData Structures- Part2 analysis tools
Data Structures- Part2 analysis toolsAbdullah Al-hazmy
 
Aad introduction
Aad introductionAad introduction
Aad introductionMr SMAK
 
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
TIME EXECUTION   OF  DIFFERENT SORTED ALGORITHMSTIME EXECUTION   OF  DIFFERENT SORTED ALGORITHMS
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMSTanya Makkar
 
DAA-Unit1.pptx
DAA-Unit1.pptxDAA-Unit1.pptx
DAA-Unit1.pptxNishaS88
 
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 algorithmDevaKumari Vijay
 
Daa unit 6_efficiency of algorithms
Daa unit 6_efficiency of algorithmsDaa unit 6_efficiency of algorithms
Daa unit 6_efficiency of algorithmssnehajiyani
 
Algorithm Analysis.pdf
Algorithm Analysis.pdfAlgorithm Analysis.pdf
Algorithm Analysis.pdfMemMem25
 
Asymptotic Analysis in Data Structure using C
Asymptotic Analysis in Data Structure using CAsymptotic Analysis in Data Structure using C
Asymptotic Analysis in Data Structure using CMeghaj Mallick
 
Data Structures and Algorithm Analysis
Data Structures  and  Algorithm AnalysisData Structures  and  Algorithm Analysis
Data Structures and Algorithm AnalysisMary Margarat
 
Data Structures and Algorithms - Lec 02.pdf
Data Structures and Algorithms - Lec 02.pdfData Structures and Algorithms - Lec 02.pdf
Data Structures and Algorithms - Lec 02.pdfRameshaFernando2
 
Analysis of Algorithm full version 2024.pptx
Analysis of Algorithm  full version  2024.pptxAnalysis of Algorithm  full version  2024.pptx
Analysis of Algorithm full version 2024.pptxrajesshs31r
 
Design Analysis of Alogorithm 1 ppt 2024.pptx
Design Analysis of Alogorithm 1 ppt 2024.pptxDesign Analysis of Alogorithm 1 ppt 2024.pptx
Design Analysis of Alogorithm 1 ppt 2024.pptxrajesshs31r
 

Similaire à Algorithm Class at KPHB (C, C++ Course Training Institute in KPHB, Kukatpally KPHB, Hyderabad.) (20)

Data Structures and Algorithms Lecture 2: Analysis of Algorithms, Asymptotic ...
Data Structures and Algorithms Lecture 2: Analysis of Algorithms, Asymptotic ...Data Structures and Algorithms Lecture 2: Analysis of Algorithms, Asymptotic ...
Data Structures and Algorithms Lecture 2: Analysis of Algorithms, Asymptotic ...
 
Data Structures- Part2 analysis tools
Data Structures- Part2 analysis toolsData Structures- Part2 analysis tools
Data Structures- Part2 analysis tools
 
Aad introduction
Aad introductionAad introduction
Aad introduction
 
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
TIME EXECUTION   OF  DIFFERENT SORTED ALGORITHMSTIME EXECUTION   OF  DIFFERENT SORTED ALGORITHMS
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
 
DAA-Unit1.pptx
DAA-Unit1.pptxDAA-Unit1.pptx
DAA-Unit1.pptx
 
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 unit 6_efficiency of algorithms
Daa unit 6_efficiency of algorithmsDaa unit 6_efficiency of algorithms
Daa unit 6_efficiency of algorithms
 
Algorithm Analysis.pdf
Algorithm Analysis.pdfAlgorithm Analysis.pdf
Algorithm Analysis.pdf
 
3 analysis.gtm
3 analysis.gtm3 analysis.gtm
3 analysis.gtm
 
Algorithms
Algorithms Algorithms
Algorithms
 
Lec1
Lec1Lec1
Lec1
 
chapter 1
chapter 1chapter 1
chapter 1
 
Chapter two
Chapter twoChapter two
Chapter two
 
Daa chapter 1
Daa chapter 1Daa chapter 1
Daa chapter 1
 
Asymptotic Analysis in Data Structure using C
Asymptotic Analysis in Data Structure using CAsymptotic Analysis in Data Structure using C
Asymptotic Analysis in Data Structure using C
 
Data Structures and Algorithm Analysis
Data Structures  and  Algorithm AnalysisData Structures  and  Algorithm Analysis
Data Structures and Algorithm Analysis
 
Data Structures and Algorithms - Lec 02.pdf
Data Structures and Algorithms - Lec 02.pdfData Structures and Algorithms - Lec 02.pdf
Data Structures and Algorithms - Lec 02.pdf
 
Analysis of Algorithm full version 2024.pptx
Analysis of Algorithm  full version  2024.pptxAnalysis of Algorithm  full version  2024.pptx
Analysis of Algorithm full version 2024.pptx
 
Design Analysis of Alogorithm 1 ppt 2024.pptx
Design Analysis of Alogorithm 1 ppt 2024.pptxDesign Analysis of Alogorithm 1 ppt 2024.pptx
Design Analysis of Alogorithm 1 ppt 2024.pptx
 
DATA STRUCTURE.pdf
DATA STRUCTURE.pdfDATA STRUCTURE.pdf
DATA STRUCTURE.pdf
 

Plus de http://algorithmtraining.com/advanced-python-training-hyderabad/

Plus de http://algorithmtraining.com/advanced-python-training-hyderabad/ (20)

Algorithm Class- Python training in hyderabad, Python online training in hyde...
Algorithm Class- Python training in hyderabad, Python online training in hyde...Algorithm Class- Python training in hyderabad, Python online training in hyde...
Algorithm Class- Python training in hyderabad, Python online training in hyde...
 
Algorithm Class at KPHB (C, C++ Course Training Institute in KPHB, Kukatpall...
Algorithm Class at KPHB  (C, C++ Course Training Institute in KPHB, Kukatpall...Algorithm Class at KPHB  (C, C++ Course Training Institute in KPHB, Kukatpall...
Algorithm Class at KPHB (C, C++ Course Training Institute in KPHB, Kukatpall...
 
Algorithm Class at KPHB (C, C++ Course Training Institute in KPHB, Kukatpally...
Algorithm Class at KPHB (C, C++ Course Training Institute in KPHB, Kukatpally...Algorithm Class at KPHB (C, C++ Course Training Institute in KPHB, Kukatpally...
Algorithm Class at KPHB (C, C++ Course Training Institute in KPHB, Kukatpally...
 
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
 
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
 
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
 
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
 
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
 
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
 
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
 
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
 
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
 
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
 
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
 
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
 
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
 
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
 
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
 
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
 
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
Algorithm Class at KPHB C, c++, ds,cpp,java,data structures training institut...
 

Dernier

Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesShubhangi Sonawane
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 

Dernier (20)

Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 

Algorithm Class at KPHB (C, C++ Course Training Institute in KPHB, Kukatpally KPHB, Hyderabad.)

  • 1. ALGORITHM CLASSS Algorithm Analysis DS C C++ JAVA TRAINING INSTITUTES IN KPHB HYDERABAD
  • 2. Program=instructions + data Description of algorithms and data structures to achieve a specific objective Could be done in any language, even a natural language like Wnglish Example add a and b Read a ; read b; c=a+b; // Algorithm A , b and c are data structures Programming language: A standard notation for writing programs Like english or telugu Examples: C, Java, intel assemly language, machine language etc Hardware understands machine language but we instructs using programming language. Hence we need the program translators like compiler gcc C++ TRAINING INSTITUTES IN KPHB HYDERABAD What is a computer program ALGORITHM CLASSS
  • 3. ALGORITHM CLASSS If you are strong with data structures, you can  evaluate the quality of a program (Analysis of Algorithms: Running time and memory space )  write fast,efficient and quality programs with less memory usage  solve new problems efficiently by choosing appropriate data structures and algorithms C++ TRAINING INSTITUTES IN KPHB HYDERABAD Why do we need this course
  • 4. ALGORITHM CLASSS  How smart you are to pick the appropriate data structure for a given problem(if you know pros and cons of different DS only you can decide)  How strong you are on programming basics (DS)  Ability to decompose problems  Ability to find solutions with a better logic  Efficient programming skills … etc. DS TRAINING INSTITUTES IN KPHB HYDERABAD Why interviewer concentrates more on DS
  • 5. ALGORITHM CLASSS Data Structures: A systematic way of organizing and accessing data . --No single data structure works well for ALL purposes. Algorithm is a step-by-step procedure for solving a problem in a finite amount of time. Algorithm analysis a process of determining the amount of time, resource, etc. required when executing an algorithm Estimate the running time Estimate the memory space required. Depends on the input size DS TRAINING INSTITUTES IN KPHB HYDERABAD What is an algorithm analysis
  • 6. ALGORITHM CLASSS There are two aspects of algorithmic performance: Time Instructions take time. How fast does the algorithm perform? What affects its runtime? Space Data structures take space What kind of data structures can be used? How does choice of data structure affect the runtime? We will focus on time: How to estimate the time required for an algorithm How to reduce the time required Analysis of Algorithms is the area of computer science that provides tools to analyze the efficiency of different methods of solutions. How do we compare the time efficiency of two algorithms that solve the same problem? Naïve Approach: implement these algorithms in a programming language (C++), and run them to compare their time requirements. Comparing the programs (instead of algorithms) has difficulties. JAVA TRAINING INSTITUTES IN KPHB HYDERABAD What is an algorithm analysis
  • 7. ALGORITHM CLASSS To analyze algorithms: First, we start to count the number of significant operations in a particular solution to assess its efficiency. Then, we will express the efficiency of algorithms using growth functions. Growth Rate We measure an algorithm’s time requirement as a function of the problem size. Problem size depends on the application: e.g. number of elements in a list for a sorting algorithm, the number disks for towers of hanoi. So, for instance, we say that (if the problem size is n) Algorithm A requires 5*n2 time units to solve a problem of size n. Algorithm B requires 7*n time units to solve a problem of size n. The most important thing to learn is how quickly the algorithm’s time requirement grows as a function of the problem size. Algorithm A requires time proportional to n2. Algorithm B requires time proportional to n. An algorithm’s proportional time requirement is known as growth rate. We can compare the efficiency of two algorithms by comparing their growth rates. C TRAINING INSTITUTES IN KPHB HYDERABAD What is an algorithm analysis
  • 8. ALGORITHM CLASSS What is an algorithm analysis Function Growth Rate Name c Constant log N Logarithmic log2N Log-squared N Linear N log N N2 Quadratic N3 Cubic 2N Exponential
  • 9. ALGORITHM CLASSS Experimental Studies Write a program implementing the algorithm Run the program with inputs of varying size and composition Use a method like System.currentTimeMillis() to get an accurate measure of the actual running time Plot the results and compare Limitations of the experiments It is necessary to implement the algorithm, which may be difficult Results may not be indicative of the running time on other inputs not included in the experiment. In order to compare two algorithms, the same hardware and software environments must be used JAVA TRAINING INSTITUTES IN KPHB HYDERABAD What is an algorithm analysis
  • 10. ALGORITHM CLASSS Theoretical Analysis Uses a high-level description of the algorithm instead of an implementation Characterizes running time as a function of the input size, n. Takes into account all possible inputs Allows us to evaluate the speed of an algorithm independent of the hardware/software environment Asymptotic Algorithm Analysis The asymptotic analysis of an algorithm determines the running time in big-Oh notation To perform the asymptotic analysis We find the worst-case number of primitive operations executed as a function of the input size We express this function with big-Oh notation What is an algorithm analysis
  • 11. (Big-Oh) T(n) is O(F(n)) if there are positive constants c and n0 such that T(n)<= cF(n) when n >= n0 Provides an upper bound on the growth rate of the function. (Big-Omega) T(n) is Ω(F(n)) if there are positive constant c and n0 such that T(n) >= cF(n) when n >= n0 we want to say that an algorithm takes at least a certain amount of time, Def: (Big-Theta) T(n) is Θ(F(n)) if and only if T(n) = O(F(n)) and T(n) = Ω(F(n)) => k1*F(n) < Def: (Little-Oh) T(n) = o(F(n)) if and only if T(n) = O(F(n)) and T(n) != Θ (F(n)) we cannot say here what the value of c_1c​1​​ is, because it depends on the speed of the computer, the programming language used, the compiler or interpreter that translates the source program into runnable code, and other factors. C++ TRAINING INSTITUTES IN KPHB HYDERABAD Algorithm analysis: other notations
  • 12. ALGORITHM CLASSS Asymptotic Algorithm Analysis The asymptotic analysis of an algorithm determines the running time in big-Oh notation To perform the asymptotic analysis We find the worst-case number of primitive operations executed as a function of the input size We express this function with big-Oh notation Example: We determine that algorithm arrayMax executes at most 6n  1 primitive operations We say that algorithm arrayMax “runs in O(n) time” Since constant factors and lower-order terms are eventually dropped anyhow, we can disregard them when counting primitive operations Algorithm analysis: BIG-Oh notation
  • 13. ALGORITHM CLASSS Big O notation: Big Oh notation is used to capture the most dominant term in a function, and to represent the growth rate. Also called asymptotic upper bound. Ex: 100n3 + 30000n =>O(n3) To simplify the running time estimation, for a function f(n), we ignore the constants and lower order terms. Example: 10n3+4n2-4n+5 is O(n3). http://sites.google.com/site/algorithmclass BIG-Oh notation
  • 15. http://sites.google.com/site/algorithmclass Theta Definition: A theoretical measure of the execution of an algorithm, usually the time or memory needed, given the problem size n, which is usually the number of items. Informally, saying some equation f(n) = Θ (g(n)) means it is within a constant multiple of g(n). The equation is read, "f of n is theta g of n". Formal Definition: f(n) = Θ (g(n)) means there are positive constants c1, c2, and k, such that 0 ≤ c1g(n) ≤ f(n) ≤ c2g(n) for all n ≥ k. The values of c1, c2, and k must be f ixed for the function f and must not depend on n.
  • 16. http://plus.google.com/+AlgorithmClass Omege (Big-Omega) T(n) is Ω(F(n)) if there are positive constant c and n0 such that T(n) >= cF(n) when n >= n0 we want to say that an algorithm takes at least a certain amount of time,
  • 17. https://plus.google.com/+AlgorithmClass BIG-Oh notation Definition: A theoretical measure of the execution of an algorithm, usually the time or memory needed, given the problem size n, which is usually the number of items. Informally, saying some equation f(n) = O(g(n)) means it is less than some constant multiple of g(n). The notation is read, "f of n is big oh of g of n". Formal Definition: f(n) = O(g(n)) means there are positive constants c and k, such that 0 ≤ f(n) ≤ cg(n) for all n ≥ k. The values of c and k must be fixed for the function f and must not depend on n.
  • 18. ALGORITHM CLASSS Primitive Operations Basic computations performed by an algorithm Largely independent from the programming language Examples: Evaluating an expression Assigning a value to a variable Indexing into an array Calling a method Returning from a method Algorithm analysis: BIG-Oh notation Algorithm arrayMax(A, n) currentMax=a[0]; // 2 for (i=1;i<n;i++) // 2n //(i=1 once, i<n n times, i++ (n-1) times) if (a[i] > currentMax) 2(n-1) currentMax=a[i] 2(n-1) return currentMax; 1 total time= 6n-1
  • 19. Function Name C Constant LogN Logarithmic Log2N Log-squared N Linear NlogN NlogN N2 Quaratic N3 Cubic 2n Exponential Algorithm analysis: BIG-Oh notation
  • 22. Worst-case vs. Average-case A worst-case bound is a guarantee over all inputs of size N. In an average-case bound, the running time is measured as an average over all of the possible inputs of size N. We will mainly focus on worst-case analysis, but sometimes it is useful to do average one. Example: Static Searching Problem Given an integer X and an array A, return the position of X in A or an indication that it is not present. If X occurs more than once, return any occurrence. The array A is never altered. Sequential search: =>O(n) Binary search (sorted data): => O(logn) BIG-Oh notation
  • 23. Sequential search A sequential search steps through the data sequentially until an match is found. A sequential search is useful when the array is not sorted. A sequential search is linear O(n) (i.e. proportional to the size of input)  Unsuccessful search --- n times  Successful search (worst) --- n times  Successful search (average) --- n/2 times Binary Search If the array has been sorted, we can use binary search, which is performed from the middle of the array rather than the end. We keep track of low_end and high_end, which delimit the portion of the array in which an item, if present, must reside. If low_end is larger than high_end, we know the item is not present. Algorithm analysis: Example
  • 24. Algorithm Class Email: algorithm.class@gmail.com Website: http://sites.google.com/site/algorithmclass G+ : http://plus.google.com/+AlgorithmClass/posts Facebook : http://www.facebook.com/AlgorithmClassCCppDsJavaTrainingKphbHyderabad ALGORITHM CLASSS C C++ DS Data Structures CPP JAVA TRAINING INSTITUTE KPHB HYDERABAD /