Professional Documents
Culture Documents
Unit 1
Unit 1
PERFORMANCE ANALYSIS:
ALGO 1.1:
Eg.Algo abc(a,b,c)
{
Return a+b+b*c+(a+b-c)/(a+b)+4.0;
}
part:
ALGO 1.2:
s=0.0;
Variable part=n
As n will determine the size of the array a[i] as it has n elements
• Instances characterized by n
• Return address requires only 1 word of memory
• Recursion is for (n+1) times
RSum(a,n-1)+a[n]
RECURSIVE ALGO:
Statements s/e Frequency Total steps
n=0 n>0 n=0 n>0
algo RSum(a,n) 0 0 0 0 0
{ 0 0 0 0 0
If (n<=0) then 1 1 1 1 1
Return 0.0 1 1 0 1 0
Else 0 0 0 0 0
return RSum(a,n-1) 1+x 0 1 0 1+x
+a[n]
} 0 0 0 0 0
Where x=RSum(a,n-1)
Total steps:
1. 2
N=0 2+x
2.
N>0
• The above is another method of calculating the complexiety of
an algo,and is called TABLE METHOD.
• Previous method is step wise complexiety calculation
• Bt table method is Comparatively an easier one
TIME COMPLEXIETY:
The equation for time complexity is T(P)=c+tp T(P)= Time Complexity
for the program Where c=constant part Tp=variable part
P=(v0,v1,v2......................vn)
Here u = v0
• If v0=vn then
The path is called CLOSED PATH.
(digraph)
■ Outdegree
■ Indegree
In graph 1.
1. adjacency matrix
2. adjacency list
3. adjacency multilist
1. ADJACENCY MATRIX:
In graph 2
Aij = 1 vi adjacent to vj for edge(vi,vj)
0 otherwise
X Y Z W
X 0 0 0 1
Y 1 0 1 1
Z 1 0 0 1
W 0 0 1 0
2. ADJACENCY LIST:
Graph 3
3. ADJACENCY MULTILIST:
(A) Node list:
DEST LINK
3 states
■ Ready
■ Waiting
■ Processed
DFS:
• To process the nodes which are reachable from starting
nodes..
• Is used to calculate MINIMUM PATH
• QUEUE is used
BFS:
• Is used to find all reachable nodes
STACK is used