SlideShare a Scribd company logo
1 of 58
Design and Analysis of Algorithms
• Objectives
To understand and learn advance algorithms
and methods used in computer science to
create strong logic and problem solving
approach in student
Ref. Book.
Fundamentals of Computer Algorithms by- Sartaj Sahni
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Key terms under study
• Problem
• Computer Science
• Analysis
• Design
• Algorithm, pseudo code and Flowchart
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Algorithm ?...
• Persian author, Abu Ja’far Mohammed abn Musa al
Khowarizmi
• Definition:
• Algorithm must satisfy following criteria:
– Input: (Instance)
– Output
– Definiteness
– Finiteness
– Effectiveness
• Algorithms that are definite & effective are also called as
Computational procedures. (OS)
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Algorithm
• Advantages
– General Purpose tool
– Independent
– Help in programming
– Help in debugging
– Easiness
• Disadvantages
– Time
– Branching & looping
– Ambiguity
– Synonyms
– No standard method
of wording and
writing of algorithm
text.
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Why Algorithms ?...
The study of algorithms includes many
important and active areas of research like –
– How to devise algorithms
– How to validate algorithm
– How to analyze algorithm
– How to test a program.
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Pseudo code Conventions…
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Algorithm Analysis
• Process of finding diff. resources required
• To make judgment of some instances like
– Does it do what we want it to do?
– Does it work correctly according to the original
specifications of the task?
– Is there documentation that describes how to use it and
how it works?
– Are procedures created in such a way that they perform
logical sub-functions?
– Is the code readable?
– What amount of computational time required?
– What amount of memory space required?
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Performance Evaluation
• Priori estimates refer as Performance Analysis
• Posterior testing refer as Performance
measurement.
• RAM – PE model – instructions are executed
one after another, with no concurrent
operations.
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Performance Analysis
• Branch of CS called as Complexity theory
• Focus on obtaining estimates of Time and
Space required for particular operation, that
are machine independent.
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Space Complexity
• Of an Algo. Is the amount of memory space it
needs to-run-to completion of the process.
• Efficiency inversely proportional to memory
• Space complexity can be calculated by
considering Data & its Size and measured on
WORD
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Space needed by any Algo is the Sum of -
– A fixed part that is independent of the characteristics (e.g.
number, size) of the inputs and outputs. This part typically
includes the instruction space (i.e. space for code), space for
simple variable and fixed size component variables (also called
aggregates), space for constants, and so on.
– A variable part that consists of the space needed by component
variables whose size is dependent on the particular problem
instance being solved, the space needed by referenced
variables, and the recursion stack space.
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
The space requirements S(P) of any algorithm p
may therefore written as –
S(P)= c + Sp(instance characteristics)
Where, c is a constant and fixed variables.
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Example :
Algorithm abc( a, b, c)
{
return a+b+c /(a+b) +7.0;
}
Space complexity for the given algorithm = c +
Sp(instance characteristics)
= 4 + 0
= 4 word.
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Example :
Algorithm Sum(a,n)
{
s:=0.0;
for i:= 1 to n do
s:= s+ a[i];
return s;
}
Space complexity for the given algorithm
= c + Sp(instance characteristics)
= (3 + n) word.
(n for a[], one each for i, s and n)
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Example :
Algorithm RSum(a,n)
{ if n≤ 0 then return a[n];
else return RSum(a, n-1)+ a[n];
}
Space complexity for the given algorithm
= c + Sp (instance characteristics)
= 3 +3(n+1)
=3n+6
= n+2 words.
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Time Complexity
• Defn.
• T(P)=Compile time +Run(Execution) Time
• To calculate time complexity, only Run
(Execution) time is taken into consideration.
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
• introduce a new variable, count, into a program by
identifying Program Step and by Increment the
value of count by appropriate amount with respect
to a statement in the original program executes.
• Program Step - A synthetically meaningful segment of a
program that requires execution time which is independent
on the instance characteristics.
Count method to calculate time complexity
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
• The number of steps in any program depends on the kind
of statements. For example –
– Comments count as zero steps
– An assignment statement which does not involves any calls to other
algorithm is counted as one step.
– For looping statements the step count equals to the number of step counts
assignable to goal value expression. And should be incremented by one
within a block and after completion of block.
– For conditional statements the step count should incremented by one before
condition statement.
– A return statement is counted as one step and should be write before return
statement.
Count method to calculate time complexity…
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
For example –
Algorithm Sum(a,n)
{ s:=0;
for i:=1 to n do
{ s:=s+a[i];
}
return s;
}
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Algorithm Sum(a,n) // After Adding Count
{ s:=0;
count:=count+1; // for assignment statement execution
for i:=1 to n do
{
count:=count+1; //for For loop Assignment
s:=s+a[i];
count:=count+1;// for addition statement execution
}
count:=count+1; // for last time of for
count:=count+1; // for the return
return s;
}
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Algorithm Sum(a,n) //Simplified version for algorithm Sum
{ for i:=1 to n do
{
count:=count+2;
}
count:=count+3;
}
Form above example,
Total number of program steps= 2n + 3, where n is
the loop counter.
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Algorithm RSum(a,n)
{
if n ≤ 0 then
return a[n];
else
return RSum(a, n-1) + a[n];
}
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Algorithm RSum(a,n)
{
count:=count + 1; // for the if condition
if n ≤ 0 then
{ count:=count + 1;// for the return statement
return a[n];
}
else
{ count:=count + 1; // for the addition, function invoked & return
return RSum(a, n-1) + a[n];
}
}
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Algorithm RSum(a,n) //Simplified version of algorithm RSum
with counting’s only
{
count:=count + 1;
if n ≤ 0 then
count:=count + 1;
else
count:=count + 1;
}
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Therefore we can write,
• tRSum(n) = 2 if n=0 and
• tRSum(n) = 2+ tRSum(n-1) if n>0
= 2+ 2+ tRSum(n – 2)
= 2(2)+ tRSum(n – 2)
=3 (2) + tRSum(n – 3)
:
:
= n(2) + tRSum(0)
=2n+2
So, the step count for RSum algorithm is 2n+2.Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Table method to calculate time complexity
• build a table in which we list the total number of steps
contributed by each statement. This table contents three
columns –
– Steps per execution (s/e)- contents count value by which count
increases after execution of that statement.
– Frequency – is the value indicating total number of times
statement executes
– Total steps – can be obtained by combining s/e and frequency.
Total step count can be calculated by adding total steps
contribution values.
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Statement s/e Frequency Total
steps
Algorithm Sum(a,n)
{
s:=0;
for i:=1 to n do
s:=s+a[i];
return s;
}
0
0
1
1
1
1
0
1
1
1
n+1
n
1
1
0
0
1
n+1
n
1
0
Total step count = 2n+3
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Asymptotic Notations
• Asymptotic Notations are the terminology,
used to make meaningful statements about
Performance Analysis of an algorithm. (i.e.
calculating the time & space complexity)
• Different Asymptotic notations used for
Performance Analysis are –
– Big ‘Oh’ notation (O)
– Omega notation ( Ω)
– Theta notation (Θ)
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Big ‘Oh’ notation (O)
• Used in Computer Science to describe the
performance or complexity of an algorithm.
• Describes the worst-case scenario, and can be
used to describe the maximum execution time
(asymptotic upper bounds) required or the
space used (e.g. in memory or on disk) by an
algorithm.
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Definition:
The function f (n) = O(g(n)) ( read as ‘f of n is
said to be big oh of g of n’) if and only if there
exists a real, positive constant C and a positive
integer n0 such that,
f (n) ≤ C*g(n) for all n≥n0
Where, n is number of inputs, g(n) is function of
the size of the input data, and f(n) is the
computing time of some algorithm.
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Examples – (‘=’ symbol readed as ‘is’ instead of ‘equal’)
• The function 3n+2 = O(n) as 3n+2 ≤ 4n for all n≥2
• The function 3n+3 = O(n) as 3n+3 ≤ 4n for all n≥3
• The function 100n+6 = O(n) as 100n+6 ≤ 101n for all n≥6
• The function 10n2
+4n+2 = O(n2
) as 10n2
+4n+2 ≤ 11n2
for all n≥5
• The function 1000n2
+100n-6 = O(n2
) as 1000n2
+100n-6 ≤
1001n2
for all n≥100
• The function 6*2n
+n2
= O(2n
) as 6*2n
+n2
≤ 7*2n
for all n≥4
• The function 3n+3 = O(n2
) as 3n+3 ≤ 3n2
for all n≥2
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
• Consider the job offers from two companies. The first
company offer contract that will double the salary every
year. The second company offers you a contract that
gives a raise of Rs. 1000 per year. This scenario can be
represented with Big-O notation as –
• For first company, New salary = Salary X 2n
(where n is
total service years)
Which can be denoted with Big-O notation as O(2n
)
• For second company, New salary = Salary +1000n
(where n is total service years)
Which can be denoted with Big-O notation as O(n)
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
O(1)
Describes an algorithm that will always execute
in the same time (or space) regardless of the
size of the input data set i.e. a computing time
is a constant time.
int IsFirstElementNull(char String[])
{ if(strings[0] == ‘0’)
{ return 1;
}
return 0;
}
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
O(N): is called linear time,
Describe an algorithm whose performance will grow
linearly and in direct proportion to the size of the
input data set.
int ContainsValue(char String[], int no, char ch)
{ for( i = 0; i < no; i++)
{ if(string[i] == ch)
{ return 1;
}
}
return 0;
}
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
O(Nk
): (k fixed) refers to polynomial time; (if k=2, it is called
quadratic time, k=3, it is called cubic time),
• which represents an algorithm whose performance is directly
proportional to the square of the size of the input data set.
• This is common with algorithms that involve nested iterations over
the data set. Deeper nested iterations will result in O(N3
), O(N4
) etc.
bool ContainsDuplicates(String[] strings)
{ for(int i = 0; i < strings.Length; i++)
{ for(int j = 0; j < strings.Length; j++)
{ if(i == j) // Don't compare with self
continue;
if(strings[i] == strings[j])
return true;
}
return false;
}
}
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
O(2N
) : is called exponential time,
• Denotes an algorithm whose growth will
double with each additional element in the
input data set.
• The execution time of an O(2N
) function will
quickly become very large.
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Omega notation (Ω)
• used in computer science to describe the
performance or complexity of an algorithm.
• specifically describes the best-case scenario,
and can be used to describe the minimum
execution time (asymptotic lower bounds)
required or the space used (e.g. in memory or
on disk) by an algorithm.
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Definition:
The function f (n) = Ω(g(n)) ( read as ‘f of n is
said to be Omega of g of n’) if and only if there
exists a real, positive constant C and a positive
integer n0 such that,
f (n) ≥ C*g(n) for all n≥ n0
Here, n0 must be greater than 0.
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Examples –
• The function 3n+2 = Ω(n) as 3n+2 ≥ 3n for all n≥1
• The function 3n+3 = Ω(n) as 3n+3 ≥ 3n for all n≥1
• The function 100n+6 = Ω(n) as 100n+6 ≥ 100n for all n≥1
• The function 10n2
+4n+2 = Ω(n2
) as 10n2
+4n+2 ≥ n2
for all n≥1
• The function 6*2n
+n2
= Ω(2n
) as 6*2n
+n2
≥ 2n
for all n≥1
• The function 3n+3 = Ω(1)
• The function 10n2
+4n+2 = Ω(n)
• The function 10n2
+4n+2 = Ω(1)
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Theta notation (Θ)
• Used in computer science to describe the
performance or complexity of an algorithm.
• Theta specifically describes the average-case
scenario, and can be used to describe the average
execution time required or the space used by an
algorithm.
• A description of a function in terms of Θ notation
usually only provides an tight bound on the growth
rate of the function.
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Definition:
• The function f (n) = Θ(g(n)) ( read as ‘f of n is
said to be Theta of g of n’) if and only if there
exists a positive constants C1, C2, and a positive
integer n0 such that,
C1*g(n) ≤ f (n) ≤ C2*g(n) for all n≥n0
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Examples –
• The function 3n+2 = Θ(n) as
3n+2 ≥ 3n for all n≥2 and
3n+2 ≤4n for all n≥2
So, c1=3, c2=4 and n0=2.
• The function 3n+3 = Θ(n)
• The function 10n2
+4n+2 = Θ (n2
)
• The function 6 * 2n
+n2
= Θ(2n
)
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Determining asymptotic complexity
• The asymptotic complexity (i.e. the complexity
in terms of O, Ω, Θ)
• can be determine by first determine the
asymptotic complexity of each statement in
the algorithm and then adding these
complexities one can determine asymptotic
complexity of an algorithm.
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Example -1: Calculate Asymptotic complexity of
Algorithm to calculate sum of array element A of size n
Algorithm Sum(a,n)
{ s:=0;
for i:=1 to n do
s:=s+a[i];
return s;
}
Asymptotic complexity of Algorithm Sum
Statement
s/e Frequency Total steps
Algorithm Sum(a,n)
{
s:=0;
for i:=1 to n do
s:=s+a[i];
return s;
}
0
0
1
1
1
1
0
1
1
1
n+1
n
1
1
Θ(0)
Θ(0)
Θ(1)
Θ(n)
Θ(n)
Θ(1)
Θ(0)
Total Asymptotic
complexity =
=Θ(2n+2)
= Θ(n)
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Practical Complexity:
• The time complexity of an algorithm is generally some
functions that depend upon instance characteristics.
• This function is very useful in determining how the time
requirements vary as the instance characteristics changes.
• The complexity function also used to compare two algorithms
that performs same task.
• Let us suppose P & Q are two algorithms used to perform
same task. Algorithm P has complexity Θ(n) and algorithm Q
has complexity Θ(n2
). Here one can declare that algorithm P is
faster than algorithm Q for sufficiently large n.
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Following example shows you function values and how
various functions grows with values of n.
log n n n log n n2
n3
2n
0
1
2
3
4
5
1
2
4
8
16
32
0
2
8
24
64
160
1
4
16
64
256
1024
1
8
64
512
4096
32768
2
4
16
256
65536
4294967296
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Performance Measurement:
• Is concern with obtaining the space and time
requirements of a particular algorithm. These quantities
depend on the compiler and options used as well as on
a computer on which the algorithm is run.
• To obtain computing or run time of a program we need
clocking procedures that returns the time values in
milliseconds.
• We can calculate time complexity with the help of C
programming language also. The time events are stores
in standard library (time.h) & accessed by statement
#include<time.h>.
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
There are two different methods for
timing events in C.
Method –I Method – II
Start timing Start=Clock(); Start=time(NULL);
Stop timing Stop=Clock(); Stop=time(NULL);
Time returned clock_t time_t
Result in
seconds
Duration=((double)(Stop –
Start)) / CLOCKS_PER_SEC
Duration=(double) difftime
(Stop, Start)
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Heaps
• example of Priority queue
• supports the operations of search min or max, insert, and delete
min or max element from a queue
• Heap is viewed as a nearly complete binary tree.
• In Heap, circle represents a node and
• the value within a circle is the value stored at that node,
• the value above the node is the corresponding index at the array
and
• the lines represents relationships between two nodes.
• The node having index value 1 is called root node or parent node
and
• other nodes connected to that node are called children’s.
• In heap Parents are always to the left of their children
1
16
2
14
3
10
6
9
7
3
4
8
5
7
8
2
9
4
10
1
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Heaps types
• Max heap:
A[Parent(i)] ≥ A[i]
• Min heap
A[Parent(i)] ≤ A[i]
• The main drawback of heap tree is
– extra time for creation of heap and
– too much movement of data.
– So it is not preferable for small list of data.
– For space requirement point of view it has no need
of extra space except temporary variable.
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Operations on Heap: Insert
• To insert an element into the heap, one add it
‘at the bottom’ of the heap and then
compares it with its parent, grandparent,
great-grandparent, and so on, until it is less
than or equal to the one of these values.
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Algorithm Insert(a,n) //Inserts a[n] into the heap which is stored at a[1: n-1]
{ i:=n;
item:=a[n];
while((i>1) and (a[(i/2)]< item)) do
{
a[i]:=a[(i/2)];
i:=[i/2];
}
a[i] :=item;
}
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
• Hipify the array element {100, 119, 118, 171,
112, 151, and 132) with suitable justifications
and diagrams.
• Insert three nodes having values 127,197,717
and Hapify with necessary adjustments
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Sets
• Set is a collection of distinguishable objects, called as members or
elements and listed inside braces.
• If set S contain numbers as 1, 2, and 3 can be written as
S={1,2,3}.
• Two sets A and B are equal, written as A=B if they contain the
same elements e.g. {1, 2, 3} = {3, 2, 1} ={2, 1, 3} etc.
• If an object x is an member of set S, we write x S (read ‘x is∈
member of S’ or ‘x is in S’)
• If an object x is not member of set S, we write x S. If all the∉
elements of a set A are contained in a set B, then we can write A
B and read as A is subset of B.⊆
• Some special notations used in sets are –
– ∅ denotes the empty set, that is, the set containing no members.
– Z denotes a set of integers, that is, the set {…….,-2, -1, 0, 1, 2, …..}
– R denotes the set of real numbers
– N denotes the set of natural numbers, that is, the set {0, 1, 2……} (some
author starts the natural number with 1 instead of 0)
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Disjoint Set
• Disjoint sets are the sets which does not have any
common elements.
• E.g. if set Si and Sj, i ≠ j, are two sets, then there exist
no elements in both Si and Sj.
• Suppose, when n=10, the elements can be partitioned
into three disjoint sets, S1={1,7,8,6}, S2={2, 5, 10} and
S3={3, 4, 9}. Possible representation of these can be
shown as –
• Each set is represented as a tree, which links the nodes
from children to the parent, rather than linking from
parent to the children
1
7 68
5
2 10
3
4 9
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Operations perform on Disjoint sets: Union
• If S1 and S2 are two disjoint sets, then their
union S1 U S2 = all elements in S1 and S2, thus
S1US2= {1, 7, 8, 9, 5, 2, 10}. This can be
represented by making one of the tree as a
sub-tree of the other, as shown bellow
To obtain the union of two disjoint sets, set the
parent field as one of the roots of other root
1
7 98
5
2 10
1
7 98 5
2 10
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
Operations perform on Disjoint sets: Find(i)
• Given the element i, find the set containing i. Thus 7 is in set
S1, 9 is in set S3 etc.
• The searching procedure of element within a set can be
accomplished easily if we keep a pointer to the root of the
tree representing that set.
• If each root has a pointer to the set name, then to determine
which set an element is currently in we follow the parent link
to the root of its tree and use the pointer to the set name, the
data representation for set S1, S2 and S3
• can be shown as
Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur

More Related Content

What's hot

Soc architecture and design
Soc architecture and designSoc architecture and design
Soc architecture and designSatya Harish
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)swapnac12
 
recurrence relations
 recurrence relations recurrence relations
recurrence relationsAnurag Cheela
 
Back propagation
Back propagationBack propagation
Back propagationNagarajan
 
Chpt9 patternmatching
Chpt9 patternmatchingChpt9 patternmatching
Chpt9 patternmatchingdbhanumahesh
 
Perceptron (neural network)
Perceptron (neural network)Perceptron (neural network)
Perceptron (neural network)EdutechLearners
 
Neural networks.ppt
Neural networks.pptNeural networks.ppt
Neural networks.pptSrinivashR3
 
P, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-HardP, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-HardAnimesh Chaturvedi
 
Divide and conquer - Quick sort
Divide and conquer - Quick sortDivide and conquer - Quick sort
Divide and conquer - Quick sortMadhu Bala
 
Feedforward neural network
Feedforward neural networkFeedforward neural network
Feedforward neural networkSopheaktra YONG
 
0.0 Introduction to theory of computation
0.0 Introduction to theory of computation0.0 Introduction to theory of computation
0.0 Introduction to theory of computationSampath Kumar S
 

What's hot (20)

Soc architecture and design
Soc architecture and designSoc architecture and design
Soc architecture and design
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
 
Lower bound
Lower boundLower bound
Lower bound
 
recurrence relations
 recurrence relations recurrence relations
recurrence relations
 
Back propagation
Back propagationBack propagation
Back propagation
 
Chpt9 patternmatching
Chpt9 patternmatchingChpt9 patternmatching
Chpt9 patternmatching
 
Perceptron (neural network)
Perceptron (neural network)Perceptron (neural network)
Perceptron (neural network)
 
Kmp
KmpKmp
Kmp
 
Neural networks.ppt
Neural networks.pptNeural networks.ppt
Neural networks.ppt
 
3.4 deterministic pda
3.4 deterministic pda3.4 deterministic pda
3.4 deterministic pda
 
String matching, naive,
String matching, naive,String matching, naive,
String matching, naive,
 
P, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-HardP, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-Hard
 
Divide and conquer - Quick sort
Divide and conquer - Quick sortDivide and conquer - Quick sort
Divide and conquer - Quick sort
 
Perceptron & Neural Networks
Perceptron & Neural NetworksPerceptron & Neural Networks
Perceptron & Neural Networks
 
Alpha beta
Alpha betaAlpha beta
Alpha beta
 
KMP String Matching Algorithm
KMP String Matching AlgorithmKMP String Matching Algorithm
KMP String Matching Algorithm
 
Feedforward neural network
Feedforward neural networkFeedforward neural network
Feedforward neural network
 
0.0 Introduction to theory of computation
0.0 Introduction to theory of computation0.0 Introduction to theory of computation
0.0 Introduction to theory of computation
 
Arm instruction set
Arm instruction setArm instruction set
Arm instruction set
 

Viewers also liked

What is research??
What is research??What is research??
What is research??Abu Bashar
 
Enterprise Resource Management by Dr. B. J. Mohite
Enterprise Resource Management by Dr. B. J. MohiteEnterprise Resource Management by Dr. B. J. Mohite
Enterprise Resource Management by Dr. B. J. MohiteZeal Education Society, Pune
 
Sales forecasting techniques
Sales forecasting techniquesSales forecasting techniques
Sales forecasting techniquesAbu Bashar
 
Queuing theory
Queuing theoryQueuing theory
Queuing theoryAbu Bashar
 
Pedagogy of science
Pedagogy of sciencePedagogy of science
Pedagogy of scienceAbu Bashar
 
Sequencing problems in Operations Research
Sequencing problems in Operations ResearchSequencing problems in Operations Research
Sequencing problems in Operations ResearchAbu Bashar
 
Gender school and society
Gender school and societyGender school and society
Gender school and societyAbu Bashar
 
Inventory Management
Inventory ManagementInventory Management
Inventory ManagementAbu Bashar
 
Simulation theory
Simulation theorySimulation theory
Simulation theoryAbu Bashar
 
Linear programming in market application
Linear programming in market applicationLinear programming in market application
Linear programming in market applicationAhmad Raza Bhatti
 
Payback model of risk management by Dr. B. J. Mohite
Payback model of risk management by Dr. B. J. MohitePayback model of risk management by Dr. B. J. Mohite
Payback model of risk management by Dr. B. J. MohiteZeal Education Society, Pune
 
Role and importance of language in the curriculum
Role and importance of language in the curriculumRole and importance of language in the curriculum
Role and importance of language in the curriculumAbu Bashar
 
Operation research complete note
Operation research  complete noteOperation research  complete note
Operation research complete notekabul university
 

Viewers also liked (20)

What is research??
What is research??What is research??
What is research??
 
Enterprise Resource Management by Dr. B. J. Mohite
Enterprise Resource Management by Dr. B. J. MohiteEnterprise Resource Management by Dr. B. J. Mohite
Enterprise Resource Management by Dr. B. J. Mohite
 
Sales forecasting techniques
Sales forecasting techniquesSales forecasting techniques
Sales forecasting techniques
 
Queuing theory
Queuing theoryQueuing theory
Queuing theory
 
Pedagogy of science
Pedagogy of sciencePedagogy of science
Pedagogy of science
 
Sequencing problems in Operations Research
Sequencing problems in Operations ResearchSequencing problems in Operations Research
Sequencing problems in Operations Research
 
Functional Modules of ERP By Dr. B. J. Mohite
Functional Modules of ERP By Dr. B. J. MohiteFunctional Modules of ERP By Dr. B. J. Mohite
Functional Modules of ERP By Dr. B. J. Mohite
 
Gender school and society
Gender school and societyGender school and society
Gender school and society
 
Inventory Management
Inventory ManagementInventory Management
Inventory Management
 
Simulation theory
Simulation theorySimulation theory
Simulation theory
 
Function Point Analysis (FPA) by Dr. B. J. Mohite
Function Point Analysis (FPA) by Dr. B. J. MohiteFunction Point Analysis (FPA) by Dr. B. J. Mohite
Function Point Analysis (FPA) by Dr. B. J. Mohite
 
Linear programming in market application
Linear programming in market applicationLinear programming in market application
Linear programming in market application
 
Greedy method by Dr. B. J. Mohite
Greedy method by Dr. B. J. MohiteGreedy method by Dr. B. J. Mohite
Greedy method by Dr. B. J. Mohite
 
Payback model of risk management by Dr. B. J. Mohite
Payback model of risk management by Dr. B. J. MohitePayback model of risk management by Dr. B. J. Mohite
Payback model of risk management by Dr. B. J. Mohite
 
Replacement Theory. by Dr. Babasaheb. J. Mohite
Replacement Theory. by  Dr. Babasaheb. J. MohiteReplacement Theory. by  Dr. Babasaheb. J. Mohite
Replacement Theory. by Dr. Babasaheb. J. Mohite
 
Software metrics by Dr. B. J. Mohite
Software metrics by Dr. B. J. MohiteSoftware metrics by Dr. B. J. Mohite
Software metrics by Dr. B. J. Mohite
 
Game theory
Game theoryGame theory
Game theory
 
Role and importance of language in the curriculum
Role and importance of language in the curriculumRole and importance of language in the curriculum
Role and importance of language in the curriculum
 
Unit 4 or
Unit 4 orUnit 4 or
Unit 4 or
 
Operation research complete note
Operation research  complete noteOperation research  complete note
Operation research complete note
 

Similar to Design and analysis of Algorithm By Dr. B. J. Mohite

Data Structures and Algorithm - Week 11 - Algorithm Analysis
Data Structures and Algorithm - Week 11 - Algorithm AnalysisData Structures and Algorithm - Week 11 - Algorithm Analysis
Data Structures and Algorithm - Week 11 - Algorithm AnalysisFerdin Joe John Joseph PhD
 
2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdf2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdfishan743441
 
Data structures algorithms basics
Data structures   algorithms basicsData structures   algorithms basics
Data structures algorithms basicsayeshasafdar8
 
Algorithm Analysis.pdf
Algorithm Analysis.pdfAlgorithm Analysis.pdf
Algorithm Analysis.pdfNayanChandak1
 
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...AntareepMajumder
 
function (mal120) By Wakil Kumar
function (mal120) By Wakil Kumarfunction (mal120) By Wakil Kumar
function (mal120) By Wakil KumarWakil Kumar
 
CS-102 DS-class_01_02 Lectures Data .pdf
CS-102 DS-class_01_02 Lectures Data .pdfCS-102 DS-class_01_02 Lectures Data .pdf
CS-102 DS-class_01_02 Lectures Data .pdfssuser034ce1
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptracha49
 
Introduction to Design Algorithm And Analysis.ppt
Introduction to Design Algorithm And Analysis.pptIntroduction to Design Algorithm And Analysis.ppt
Introduction to Design Algorithm And Analysis.pptBhargaviDalal4
 
01 Introduction to analysis of Algorithms.pptx
01 Introduction to analysis of Algorithms.pptx01 Introduction to analysis of Algorithms.pptx
01 Introduction to analysis of Algorithms.pptxssuser586772
 

Similar to Design and analysis of Algorithm By Dr. B. J. Mohite (20)

Algorithms.pdf
Algorithms.pdfAlgorithms.pdf
Algorithms.pdf
 
Data Structures and Algorithm - Week 11 - Algorithm Analysis
Data Structures and Algorithm - Week 11 - Algorithm AnalysisData Structures and Algorithm - Week 11 - Algorithm Analysis
Data Structures and Algorithm - Week 11 - Algorithm Analysis
 
Getting_Start_MATLAB_BVM1.pptx
Getting_Start_MATLAB_BVM1.pptxGetting_Start_MATLAB_BVM1.pptx
Getting_Start_MATLAB_BVM1.pptx
 
2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdf2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdf
 
Data structures algorithms basics
Data structures   algorithms basicsData structures   algorithms basics
Data structures algorithms basics
 
Algorithm Analysis.pdf
Algorithm Analysis.pdfAlgorithm Analysis.pdf
Algorithm Analysis.pdf
 
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
 
UNIT-2-PPTS-DAA.ppt
UNIT-2-PPTS-DAA.pptUNIT-2-PPTS-DAA.ppt
UNIT-2-PPTS-DAA.ppt
 
function (mal120) By Wakil Kumar
function (mal120) By Wakil Kumarfunction (mal120) By Wakil Kumar
function (mal120) By Wakil Kumar
 
CS-102 DS-class_01_02 Lectures Data .pdf
CS-102 DS-class_01_02 Lectures Data .pdfCS-102 DS-class_01_02 Lectures Data .pdf
CS-102 DS-class_01_02 Lectures Data .pdf
 
DSA
DSADSA
DSA
 
Unit ii algorithm
Unit   ii algorithmUnit   ii algorithm
Unit ii algorithm
 
10.ppt
10.ppt10.ppt
10.ppt
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.ppt
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.ppt
 
Introduction to Design Algorithm And Analysis.ppt
Introduction to Design Algorithm And Analysis.pptIntroduction to Design Algorithm And Analysis.ppt
Introduction to Design Algorithm And Analysis.ppt
 
01 Introduction to analysis of Algorithms.pptx
01 Introduction to analysis of Algorithms.pptx01 Introduction to analysis of Algorithms.pptx
01 Introduction to analysis of Algorithms.pptx
 
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++ 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++ 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...
 

More from Zeal Education Society, Pune

More from Zeal Education Society, Pune (8)

Knowledge Management System By Dr. B. J. Mohite
Knowledge Management System By Dr. B. J. MohiteKnowledge Management System By Dr. B. J. Mohite
Knowledge Management System By Dr. B. J. Mohite
 
Ms-Project by Dr. B. J. Mohite
Ms-Project by Dr. B. J. MohiteMs-Project by Dr. B. J. Mohite
Ms-Project by Dr. B. J. Mohite
 
COCOMO Model By Dr. B. J. Mohite
COCOMO Model By Dr. B. J. MohiteCOCOMO Model By Dr. B. J. Mohite
COCOMO Model By Dr. B. J. Mohite
 
Software Project Management by Dr. B. J. Mohite
Software Project Management by Dr. B. J. MohiteSoftware Project Management by Dr. B. J. Mohite
Software Project Management by Dr. B. J. Mohite
 
Fundamentals of Organizational Behavior by Dr. B. J. Mohite
Fundamentals of Organizational Behavior by Dr. B. J. MohiteFundamentals of Organizational Behavior by Dr. B. J. Mohite
Fundamentals of Organizational Behavior by Dr. B. J. Mohite
 
Managerial Decision Making by Dr. B. J. Mohite
Managerial Decision Making by Dr. B. J. MohiteManagerial Decision Making by Dr. B. J. Mohite
Managerial Decision Making by Dr. B. J. Mohite
 
Principles and Practices of Management By Dr. B. J. Mohite
Principles and Practices of Management By Dr. B. J. MohitePrinciples and Practices of Management By Dr. B. J. Mohite
Principles and Practices of Management By Dr. B. J. Mohite
 
Queuing Theory by Dr. B. J. Mohite
Queuing Theory by Dr. B. J. MohiteQueuing Theory by Dr. B. J. Mohite
Queuing Theory by Dr. B. J. Mohite
 

Recently uploaded

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
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
 

Recently uploaded (20)

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
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 ...
 

Design and analysis of Algorithm By Dr. B. J. Mohite

  • 1. Design and Analysis of Algorithms • Objectives To understand and learn advance algorithms and methods used in computer science to create strong logic and problem solving approach in student Ref. Book. Fundamentals of Computer Algorithms by- Sartaj Sahni Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 2. Key terms under study • Problem • Computer Science • Analysis • Design • Algorithm, pseudo code and Flowchart Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 3. Algorithm ?... • Persian author, Abu Ja’far Mohammed abn Musa al Khowarizmi • Definition: • Algorithm must satisfy following criteria: – Input: (Instance) – Output – Definiteness – Finiteness – Effectiveness • Algorithms that are definite & effective are also called as Computational procedures. (OS) Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 4. Algorithm • Advantages – General Purpose tool – Independent – Help in programming – Help in debugging – Easiness • Disadvantages – Time – Branching & looping – Ambiguity – Synonyms – No standard method of wording and writing of algorithm text. Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 5. Why Algorithms ?... The study of algorithms includes many important and active areas of research like – – How to devise algorithms – How to validate algorithm – How to analyze algorithm – How to test a program. Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 6. Pseudo code Conventions… Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 7. Algorithm Analysis • Process of finding diff. resources required • To make judgment of some instances like – Does it do what we want it to do? – Does it work correctly according to the original specifications of the task? – Is there documentation that describes how to use it and how it works? – Are procedures created in such a way that they perform logical sub-functions? – Is the code readable? – What amount of computational time required? – What amount of memory space required? Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 8. Performance Evaluation • Priori estimates refer as Performance Analysis • Posterior testing refer as Performance measurement. • RAM – PE model – instructions are executed one after another, with no concurrent operations. Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 9. Performance Analysis • Branch of CS called as Complexity theory • Focus on obtaining estimates of Time and Space required for particular operation, that are machine independent. Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 10. Space Complexity • Of an Algo. Is the amount of memory space it needs to-run-to completion of the process. • Efficiency inversely proportional to memory • Space complexity can be calculated by considering Data & its Size and measured on WORD Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 11. Space needed by any Algo is the Sum of - – A fixed part that is independent of the characteristics (e.g. number, size) of the inputs and outputs. This part typically includes the instruction space (i.e. space for code), space for simple variable and fixed size component variables (also called aggregates), space for constants, and so on. – A variable part that consists of the space needed by component variables whose size is dependent on the particular problem instance being solved, the space needed by referenced variables, and the recursion stack space. Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 12. The space requirements S(P) of any algorithm p may therefore written as – S(P)= c + Sp(instance characteristics) Where, c is a constant and fixed variables. Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 13. Example : Algorithm abc( a, b, c) { return a+b+c /(a+b) +7.0; } Space complexity for the given algorithm = c + Sp(instance characteristics) = 4 + 0 = 4 word. Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 14. Example : Algorithm Sum(a,n) { s:=0.0; for i:= 1 to n do s:= s+ a[i]; return s; } Space complexity for the given algorithm = c + Sp(instance characteristics) = (3 + n) word. (n for a[], one each for i, s and n) Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 15. Example : Algorithm RSum(a,n) { if n≤ 0 then return a[n]; else return RSum(a, n-1)+ a[n]; } Space complexity for the given algorithm = c + Sp (instance characteristics) = 3 +3(n+1) =3n+6 = n+2 words. Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 16. Time Complexity • Defn. • T(P)=Compile time +Run(Execution) Time • To calculate time complexity, only Run (Execution) time is taken into consideration. Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 17. • introduce a new variable, count, into a program by identifying Program Step and by Increment the value of count by appropriate amount with respect to a statement in the original program executes. • Program Step - A synthetically meaningful segment of a program that requires execution time which is independent on the instance characteristics. Count method to calculate time complexity Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 18. • The number of steps in any program depends on the kind of statements. For example – – Comments count as zero steps – An assignment statement which does not involves any calls to other algorithm is counted as one step. – For looping statements the step count equals to the number of step counts assignable to goal value expression. And should be incremented by one within a block and after completion of block. – For conditional statements the step count should incremented by one before condition statement. – A return statement is counted as one step and should be write before return statement. Count method to calculate time complexity… Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 19. For example – Algorithm Sum(a,n) { s:=0; for i:=1 to n do { s:=s+a[i]; } return s; } Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 20. Algorithm Sum(a,n) // After Adding Count { s:=0; count:=count+1; // for assignment statement execution for i:=1 to n do { count:=count+1; //for For loop Assignment s:=s+a[i]; count:=count+1;// for addition statement execution } count:=count+1; // for last time of for count:=count+1; // for the return return s; } Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 21. Algorithm Sum(a,n) //Simplified version for algorithm Sum { for i:=1 to n do { count:=count+2; } count:=count+3; } Form above example, Total number of program steps= 2n + 3, where n is the loop counter. Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 22. Algorithm RSum(a,n) { if n ≤ 0 then return a[n]; else return RSum(a, n-1) + a[n]; } Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 23. Algorithm RSum(a,n) { count:=count + 1; // for the if condition if n ≤ 0 then { count:=count + 1;// for the return statement return a[n]; } else { count:=count + 1; // for the addition, function invoked & return return RSum(a, n-1) + a[n]; } } Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 24. Algorithm RSum(a,n) //Simplified version of algorithm RSum with counting’s only { count:=count + 1; if n ≤ 0 then count:=count + 1; else count:=count + 1; } Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 25. Therefore we can write, • tRSum(n) = 2 if n=0 and • tRSum(n) = 2+ tRSum(n-1) if n>0 = 2+ 2+ tRSum(n – 2) = 2(2)+ tRSum(n – 2) =3 (2) + tRSum(n – 3) : : = n(2) + tRSum(0) =2n+2 So, the step count for RSum algorithm is 2n+2.Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 26. Table method to calculate time complexity • build a table in which we list the total number of steps contributed by each statement. This table contents three columns – – Steps per execution (s/e)- contents count value by which count increases after execution of that statement. – Frequency – is the value indicating total number of times statement executes – Total steps – can be obtained by combining s/e and frequency. Total step count can be calculated by adding total steps contribution values. Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 27. Statement s/e Frequency Total steps Algorithm Sum(a,n) { s:=0; for i:=1 to n do s:=s+a[i]; return s; } 0 0 1 1 1 1 0 1 1 1 n+1 n 1 1 0 0 1 n+1 n 1 0 Total step count = 2n+3 Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 28. Asymptotic Notations • Asymptotic Notations are the terminology, used to make meaningful statements about Performance Analysis of an algorithm. (i.e. calculating the time & space complexity) • Different Asymptotic notations used for Performance Analysis are – – Big ‘Oh’ notation (O) – Omega notation ( Ω) – Theta notation (Θ) Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 29. Big ‘Oh’ notation (O) • Used in Computer Science to describe the performance or complexity of an algorithm. • Describes the worst-case scenario, and can be used to describe the maximum execution time (asymptotic upper bounds) required or the space used (e.g. in memory or on disk) by an algorithm. Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 30. Definition: The function f (n) = O(g(n)) ( read as ‘f of n is said to be big oh of g of n’) if and only if there exists a real, positive constant C and a positive integer n0 such that, f (n) ≤ C*g(n) for all n≥n0 Where, n is number of inputs, g(n) is function of the size of the input data, and f(n) is the computing time of some algorithm. Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 31. Examples – (‘=’ symbol readed as ‘is’ instead of ‘equal’) • The function 3n+2 = O(n) as 3n+2 ≤ 4n for all n≥2 • The function 3n+3 = O(n) as 3n+3 ≤ 4n for all n≥3 • The function 100n+6 = O(n) as 100n+6 ≤ 101n for all n≥6 • The function 10n2 +4n+2 = O(n2 ) as 10n2 +4n+2 ≤ 11n2 for all n≥5 • The function 1000n2 +100n-6 = O(n2 ) as 1000n2 +100n-6 ≤ 1001n2 for all n≥100 • The function 6*2n +n2 = O(2n ) as 6*2n +n2 ≤ 7*2n for all n≥4 • The function 3n+3 = O(n2 ) as 3n+3 ≤ 3n2 for all n≥2 Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 32. • Consider the job offers from two companies. The first company offer contract that will double the salary every year. The second company offers you a contract that gives a raise of Rs. 1000 per year. This scenario can be represented with Big-O notation as – • For first company, New salary = Salary X 2n (where n is total service years) Which can be denoted with Big-O notation as O(2n ) • For second company, New salary = Salary +1000n (where n is total service years) Which can be denoted with Big-O notation as O(n) Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 33. O(1) Describes an algorithm that will always execute in the same time (or space) regardless of the size of the input data set i.e. a computing time is a constant time. int IsFirstElementNull(char String[]) { if(strings[0] == ‘0’) { return 1; } return 0; } Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 34. O(N): is called linear time, Describe an algorithm whose performance will grow linearly and in direct proportion to the size of the input data set. int ContainsValue(char String[], int no, char ch) { for( i = 0; i < no; i++) { if(string[i] == ch) { return 1; } } return 0; } Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 35. O(Nk ): (k fixed) refers to polynomial time; (if k=2, it is called quadratic time, k=3, it is called cubic time), • which represents an algorithm whose performance is directly proportional to the square of the size of the input data set. • This is common with algorithms that involve nested iterations over the data set. Deeper nested iterations will result in O(N3 ), O(N4 ) etc. bool ContainsDuplicates(String[] strings) { for(int i = 0; i < strings.Length; i++) { for(int j = 0; j < strings.Length; j++) { if(i == j) // Don't compare with self continue; if(strings[i] == strings[j]) return true; } return false; } } Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 36. O(2N ) : is called exponential time, • Denotes an algorithm whose growth will double with each additional element in the input data set. • The execution time of an O(2N ) function will quickly become very large. Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 37. Omega notation (Ω) • used in computer science to describe the performance or complexity of an algorithm. • specifically describes the best-case scenario, and can be used to describe the minimum execution time (asymptotic lower bounds) required or the space used (e.g. in memory or on disk) by an algorithm. Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 38. Definition: The function f (n) = Ω(g(n)) ( read as ‘f of n is said to be Omega of g of n’) if and only if there exists a real, positive constant C and a positive integer n0 such that, f (n) ≥ C*g(n) for all n≥ n0 Here, n0 must be greater than 0. Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 39. Examples – • The function 3n+2 = Ω(n) as 3n+2 ≥ 3n for all n≥1 • The function 3n+3 = Ω(n) as 3n+3 ≥ 3n for all n≥1 • The function 100n+6 = Ω(n) as 100n+6 ≥ 100n for all n≥1 • The function 10n2 +4n+2 = Ω(n2 ) as 10n2 +4n+2 ≥ n2 for all n≥1 • The function 6*2n +n2 = Ω(2n ) as 6*2n +n2 ≥ 2n for all n≥1 • The function 3n+3 = Ω(1) • The function 10n2 +4n+2 = Ω(n) • The function 10n2 +4n+2 = Ω(1) Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 40. Theta notation (Θ) • Used in computer science to describe the performance or complexity of an algorithm. • Theta specifically describes the average-case scenario, and can be used to describe the average execution time required or the space used by an algorithm. • A description of a function in terms of Θ notation usually only provides an tight bound on the growth rate of the function. Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 41. Definition: • The function f (n) = Θ(g(n)) ( read as ‘f of n is said to be Theta of g of n’) if and only if there exists a positive constants C1, C2, and a positive integer n0 such that, C1*g(n) ≤ f (n) ≤ C2*g(n) for all n≥n0 Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 42. Examples – • The function 3n+2 = Θ(n) as 3n+2 ≥ 3n for all n≥2 and 3n+2 ≤4n for all n≥2 So, c1=3, c2=4 and n0=2. • The function 3n+3 = Θ(n) • The function 10n2 +4n+2 = Θ (n2 ) • The function 6 * 2n +n2 = Θ(2n ) Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 43. Determining asymptotic complexity • The asymptotic complexity (i.e. the complexity in terms of O, Ω, Θ) • can be determine by first determine the asymptotic complexity of each statement in the algorithm and then adding these complexities one can determine asymptotic complexity of an algorithm. Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 44. Example -1: Calculate Asymptotic complexity of Algorithm to calculate sum of array element A of size n Algorithm Sum(a,n) { s:=0; for i:=1 to n do s:=s+a[i]; return s; } Asymptotic complexity of Algorithm Sum Statement s/e Frequency Total steps Algorithm Sum(a,n) { s:=0; for i:=1 to n do s:=s+a[i]; return s; } 0 0 1 1 1 1 0 1 1 1 n+1 n 1 1 Θ(0) Θ(0) Θ(1) Θ(n) Θ(n) Θ(1) Θ(0) Total Asymptotic complexity = =Θ(2n+2) = Θ(n) Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 45. Practical Complexity: • The time complexity of an algorithm is generally some functions that depend upon instance characteristics. • This function is very useful in determining how the time requirements vary as the instance characteristics changes. • The complexity function also used to compare two algorithms that performs same task. • Let us suppose P & Q are two algorithms used to perform same task. Algorithm P has complexity Θ(n) and algorithm Q has complexity Θ(n2 ). Here one can declare that algorithm P is faster than algorithm Q for sufficiently large n. Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 46. Following example shows you function values and how various functions grows with values of n. log n n n log n n2 n3 2n 0 1 2 3 4 5 1 2 4 8 16 32 0 2 8 24 64 160 1 4 16 64 256 1024 1 8 64 512 4096 32768 2 4 16 256 65536 4294967296 Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 47. Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 48. Performance Measurement: • Is concern with obtaining the space and time requirements of a particular algorithm. These quantities depend on the compiler and options used as well as on a computer on which the algorithm is run. • To obtain computing or run time of a program we need clocking procedures that returns the time values in milliseconds. • We can calculate time complexity with the help of C programming language also. The time events are stores in standard library (time.h) & accessed by statement #include<time.h>. Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 49. There are two different methods for timing events in C. Method –I Method – II Start timing Start=Clock(); Start=time(NULL); Stop timing Stop=Clock(); Stop=time(NULL); Time returned clock_t time_t Result in seconds Duration=((double)(Stop – Start)) / CLOCKS_PER_SEC Duration=(double) difftime (Stop, Start) Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 50. Heaps • example of Priority queue • supports the operations of search min or max, insert, and delete min or max element from a queue • Heap is viewed as a nearly complete binary tree. • In Heap, circle represents a node and • the value within a circle is the value stored at that node, • the value above the node is the corresponding index at the array and • the lines represents relationships between two nodes. • The node having index value 1 is called root node or parent node and • other nodes connected to that node are called children’s. • In heap Parents are always to the left of their children 1 16 2 14 3 10 6 9 7 3 4 8 5 7 8 2 9 4 10 1 Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 51. Heaps types • Max heap: A[Parent(i)] ≥ A[i] • Min heap A[Parent(i)] ≤ A[i] • The main drawback of heap tree is – extra time for creation of heap and – too much movement of data. – So it is not preferable for small list of data. – For space requirement point of view it has no need of extra space except temporary variable. Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 52. Operations on Heap: Insert • To insert an element into the heap, one add it ‘at the bottom’ of the heap and then compares it with its parent, grandparent, great-grandparent, and so on, until it is less than or equal to the one of these values. Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 53. Algorithm Insert(a,n) //Inserts a[n] into the heap which is stored at a[1: n-1] { i:=n; item:=a[n]; while((i>1) and (a[(i/2)]< item)) do { a[i]:=a[(i/2)]; i:=[i/2]; } a[i] :=item; } Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 54. • Hipify the array element {100, 119, 118, 171, 112, 151, and 132) with suitable justifications and diagrams. • Insert three nodes having values 127,197,717 and Hapify with necessary adjustments Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 55. Sets • Set is a collection of distinguishable objects, called as members or elements and listed inside braces. • If set S contain numbers as 1, 2, and 3 can be written as S={1,2,3}. • Two sets A and B are equal, written as A=B if they contain the same elements e.g. {1, 2, 3} = {3, 2, 1} ={2, 1, 3} etc. • If an object x is an member of set S, we write x S (read ‘x is∈ member of S’ or ‘x is in S’) • If an object x is not member of set S, we write x S. If all the∉ elements of a set A are contained in a set B, then we can write A B and read as A is subset of B.⊆ • Some special notations used in sets are – – ∅ denotes the empty set, that is, the set containing no members. – Z denotes a set of integers, that is, the set {…….,-2, -1, 0, 1, 2, …..} – R denotes the set of real numbers – N denotes the set of natural numbers, that is, the set {0, 1, 2……} (some author starts the natural number with 1 instead of 0) Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 56. Disjoint Set • Disjoint sets are the sets which does not have any common elements. • E.g. if set Si and Sj, i ≠ j, are two sets, then there exist no elements in both Si and Sj. • Suppose, when n=10, the elements can be partitioned into three disjoint sets, S1={1,7,8,6}, S2={2, 5, 10} and S3={3, 4, 9}. Possible representation of these can be shown as – • Each set is represented as a tree, which links the nodes from children to the parent, rather than linking from parent to the children 1 7 68 5 2 10 3 4 9 Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 57. Operations perform on Disjoint sets: Union • If S1 and S2 are two disjoint sets, then their union S1 U S2 = all elements in S1 and S2, thus S1US2= {1, 7, 8, 9, 5, 2, 10}. This can be represented by making one of the tree as a sub-tree of the other, as shown bellow To obtain the union of two disjoint sets, set the parent field as one of the roots of other root 1 7 98 5 2 10 1 7 98 5 2 10 Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur
  • 58. Operations perform on Disjoint sets: Find(i) • Given the element i, find the set containing i. Thus 7 is in set S1, 9 is in set S3 etc. • The searching procedure of element within a set can be accomplished easily if we keep a pointer to the root of the tree representing that set. • If each root has a pointer to the set name, then to determine which set an element is currently in we follow the parent link to the root of its tree and use the pointer to the set name, the data representation for set S1, S2 and S3 • can be shown as Prof. B. J. Mohite @ Sinhgad Institute of Business Management, Kamlapur