Space Complexity Analysis of Iterative Algorithm & Recursive Algorithm
Space Complexity Analysis of Iterative Algorithm & Recursive Algorithm
Complexity
Analysis of
Iterative
Algorithm &
Space Complexity Analysis of Iterative
Recursive
Algorithm Algorithm & Recursive Algorithm
Dr. Munesh
Singh
Space
Complexity
Analysis of
Iterative
Algorithm &
Recursive
Algorithm
Dr. Munesh If n will be the size of the problem, and n memory block is
Singh
required then space complexity O(n)
If n will be the size of the problem, and 10 memory block
is required then space complexity O(1)
if n will be the size of the problem, and n more memory
block is required then space complexity O(n2 )
Iterative Algorithm Space Compleixty
Space
Complexity
Analysis of
Space complexity O(1)
Iterative
Algorithm &
1 Algo(A,1,n)
Recursive
Algorithm 2 {
Dr. Munesh 3 int i;
Singh
Space complexity O(n2 )
4 for(i=1to n)
1 Algo(A,1,n)
5 A[i]=0;
2 {
6 }
3 int i,j;
4 create B[n,n];
Space complexity O(n)
5 for(i=1 to n)
1 Algo(A,1,n)
6 for(j=1 to n)
2 {
7 B[i,j]=A[i];
3 int i;
8 }
4 create B[n];
Space COmplexity of Recursive Algo
Space
Complexity
Analysis of
Iterative
Algorithm &
Tree Method (small)
Recursive
A(3)
Algorithm Tree Method (small)
Dr. Munesh
Singh 1 A(n) A(3)
2 {
A(2) pf
3 if(n>= 1)
4 { Kbits
A(1) pf Kbits
5 A(n-1);
6 pf(n); Kbits
A(0) pf Kbits
7 }
n-->O(n+1) Stack
O(n)
Space Complexity of Recursive Algo
Space
Complexity
Analysis of
Iterative
Algorithm &
Recursive Tree Method (small)
Algorithm
Dr. Munesh
1 A(n) Tree Method (small)
Singh
2 { A(3)
3 if(n>= 1) A(2) pf
A(2)
A(1) pf A(1)
4 { A(1) pf A(1)
Space
Complexity
Analysis of
Iterative
Algorithm &
In divide and conquer approach, the problem is hard, is
Recursive
Algorithm
divided into smaller sub-problem.
Dr. Munesh Subproblem is solved independently
Singh
Divide and Conquer
Space
Complexity Algorithms
Analysis of
Iterative
Algorithm &
Quick Sort
Recursive
Algorithm Merge Sort
Dr. Munesh
Singh
Binary Search