Ada Final
Ada Final
LABORATORY MANUAL
Objectives
To provide quality education and groom top-notch professionals, entrepreneurs and leaders for
different fields of engineering, technology and management.
To open a Training-R & D-Design-Consultancy cell in each department, gradually introduce doctoral
and postdoctoral programs, encourage basic & applied research in areas of social relevance, and
develop the institute as a center of excellence.
To develop academic, professional and financial alliances with the industry as well as the academia at
national and transnational levels
To develop academic, professional and financial alliances with the industry as well as the academia at
national and transnational levels.
To cultivate strong community relationships and involve the students and the staff in local community
service.
To constantly enhance the value of the educational inputs with the participation of students, faculty,
parents and industry.
Vision
Development of academically excellent, culturally vibrant, socially responsible and globally competent
human resources.
Mission
To keep pace with advancements in knowledge and make the students competitive and capable at the
global level.
To create an environment for the students to acquire the right physical, intellectual, emotional and
moral foundations and shine as torch bearers of tomorrow’s society.
To strive to attain ever-higher benchmarks of educational excellence.
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING AND ENGINEERING
• To impart technical education in the field of data science of excellent quality with a high level of
professional competence, social responsibility, and global awareness among the students
Mission
• To impart technical education that is up to date, relevant and makes students competitive and employable
at global level
• To provide technical education with a high sense of discipline, social relevance in an intellectually,
ethically and socially challenging environment for better tomorrow
• Educate to the global standards with a benchmark of excellence and to kindle the spirit of innovation.
Program Outcomes(PO)
Problem analysis: Identify, formulate, review research literature, and analyze complex engineering
problems reaching substantiated conclusions using first principles of mathematics, natural sciences, and
engineering sciences.
Design/development of solutions: Design solutions for complex engineering problems and design system
components or processes that meet the specified needs with appropriate consideration for the public health
and safety, and the cultural, societal, and environmental
considerations.
Conduct investigations of complex problems: Use research-based knowledge and research methods
including design of experiments, analysis and interpretation of data, and synthesis of the information to
provide valid conclusions.
Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern engineering
and IT tools including prediction and modeling to complex engineering activities with an understanding
of the limitations.
The engineer and society: Apply reasoning informed by the contextual knowledge to assess societal,
health, safety, legal and cultural issues and the consequent responsibilities relevant to the professional
engineering practice
Environment and sustainability: Understand the impact of the professional engineering solutions in
societal and environmental contexts, and demonstrate the knowledge of, and need for sustainable
development.
Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of the
engineering practice.
Individual and team work: Function effectively as an individual, and as a member or leader in diverse
teams, and in multidisciplinary settings.
Project management and finance: Demonstrate knowledge and understanding of the engineering and
management principles and apply these to one’s own work, as a member and leader in a team, to manage
projects and in multidisciplinary environments.
Life-long learning: Recognize the need for, and have the preparation and ability to engage in independent
and life-long learning in the broadest context of technological change.
PSO2: Apply data science concepts and algorithms to solve real world problems of the society
PSO3: Apply data science techniques in the various domains like agriculture, education healthcare for
better society
PEO1: Develop cutting-edge skills in data science and its related technologies, such as machine learning,
predictive analytic, and data engineering.
PEO2: Design and develop data-driven solutions to real-world problems in a business, research, or social
environment.
PEO3: Apply data engineering and data visualization techniques to discover, investigate, and interpret data.
PEO5: Integrate fields within computer science, optimization, and statistics to develop better solutions
Sl.NO Experiments
1 Design and implement C/C++ Program to find Minimum Cost Spanning Tree of a given connected
undirected graph using Kruskal's algorithm.
2 Design and implement C/C++ Program to find Minimum Cost Spanning Tree of a given connected
undirected graph using Prim's algorithm.
3 a. Design and implement C/C++ Program to solve All-Pairs Shortest Paths problem using Floyd's
algorithm.
b. Design and implement C/C++ Program to find the transitive closure using Warshal's
algorithm.
4 Design and implement C/C++ Program to find shortest paths from a given vertex in a weighted
connected graph to other vertices using Dijkstra's algorithm.
5 Design and implement C/C++ Program to obtain the Topological ordering of vertices in a given
digraph.
Design and implement C/C++ Program to solve 0/1 Knapsack problem using Dynamic
6 Programming method.
7 Design and implement C/C++ Program to solve discrete Knapsack and continuous Knapsack
problems using greedy approximation method.
8 Design and implement C/C++ Program to find a subset of a given set S = {sl , s2,.....,sn} of n
positive integers whose sum is equal to a given positive integer d.
9 Design and implement C/C++ Program to sort a given set of n integer elements using Selection Sort
method and compute its time complexity. Run the program for varied values of n> 5000 and record the
time taken to sort. Plot a graph of the time taken versus n. The elements can be read
from a file or can be generated using the random number generator.
10 Design and implement C/C++ Program to sort a given set of n integer elements using Quick Sort method
and compute its time complexity. Run the program for varied values of n> 5000 and record the time
taken to sort. Plot a graph of the time taken versus n. The elements can be read
from a file or can be generated using the random number generator.
11 Design and implement C/C++ Program to sort a given set of n integer elements using Merge Sort method
and compute its time complexity. Run the program for varied values of n> 5000, and record the time
taken to sort. Plot a graph of the time taken versus n. The elements can be read
from a file or can be generated using the random number generator.
12 Design and implement C/C++ Program for N Queen's problem using Backtracking.
CHAPTER 1
INTRODUCTION
Need for studying algorithms
Theoretical importance
Algorithm
An algorithm is a sequence of unambiguous instructions for solving a problem, i.e., for obtaining a
required output for any legitimate input in a finite amount oftime.
In addition, all algorithms must satisfy the following criteria:
1. Input:Each algorithm should have zero or more inputs. The range of input for which algorithms
works should be specified carefully.
2. Output:The algorithm should produce correct results. At least one quantity has to be produced.
3. Definiteness: Each instruction should be clear and unambiguous.
4. Effectiveness: Every instruction should be simple and should transform the given Input to the
desired output. so that it can be carried out, in
5. Finiteness:If we trace out the instruction of an algorithm, then for all cases, the algorithm must
terminate after a finite numb2er of steps.
Notion of algorithm
Problem
Algorithm
Input Outpu
t
“Computer”
• Sorting
It refers to the problem of re-arranging the items of a given list in ascending or descending
order. The various algorithms that can be used for sorting are bubble sort, selection sort, insertion
sort, quick sort, merge sort, heap sort etc.
• Searching
This problem deals with finding a value, called a search key, in a given set.
The various algorithms that can be used for searching are binary
search, linear search, hashing, interpolation search etc.
• String processing
This problem deals with manipulation of characters or strings, string matching,
search and replace, deleting a string in a text etc.
String processing algorithm such as string matching algorithms is used in the
design of assemblers and compliers.
• Graph problems
The graph is a collection of vertices and edges.
• Combinatorial problems
These problems are used to find combinatorial object such as permutation and
combinations.
Ex: travelling salesman problem, graph coloring problem etc
• Geometric problems
This problem dealwith geometric objects such as points, curves, lines, polygon
etc. Ex:closest-pair problem, convex hull problem
• Numerical problems
These problems involving mathematical manipulations solving equations,
computing differentiations and integrations, evaluating various types of functions
etc.
Ex: Gauss elimination method, Newton-Rap son method
2. Graphs
A data structure that consists of a set of nodes and a set of edges that relate the nodes
to each other is called a graph.
3. Tree
A tree is a connected acyclic graphthat has no cycle.
Analysis of algorithms
Worst-case efficiency:
Efficiency (number of times the basic operation will be executed) for the worst case
input of size n. i.e. The algorithm runs the longest among all possible inputs of size n.
Best-case efficiency:
Efficiency (number of times the basic operationwill be executed for the best case
input of size n. i.e. The algorithm runs the fastest among all possible inputs of size n.
Average-case efficiency:
Average time taken(number of times the basic operationwill be executed) to solve all the
Asymptotic Notations
Asymptotic notation is a way of comparing functions that ignores constant factors
and small input sizes.
Three notations used to compare orders of growth of an algorithm’s basic operation are:
O, Ω, θ notations.
Big-oh notation:
A function t(n) is said to be in O(g(n)),denoted t(n)€O(g(n)),if t(n) is bounded above by some
constant multiple of g(n) for all large n i.e., if there exist some positive constant c and some
nonnegative integer n۪ 0 such that t (n)<=cg(n) for all n>= n0
Big-omega notation:
A function t(n) is said to be inΩ(g(n)),denoted t(n)€ Ω(g(n)),ift(n) is bounded below by
some constant multiple of g(n) for all large n i.e., if there exist some positive constant c and
Some nonnegative integer n۪ 0 suchthat
Big-theta
Efficiency classes:
1 constant
log n logarithmic
N linear
n log n n log n
n2 quadratic
n3 cubic
2n exponential
n! factorial
1. Design and implement C/C++ Program to find Minimum Cost Spanning Tree of a given connected
undirected graph using Kruskal's algorithm.
#include<stdio.h>
#include<stdlib.h>
int i,j,k,a,b,u,v,n,ne=1;
int min,mincost=0,cost[9][9],parent[9];
int find(int);
int uni(int,int);
void main()
{
printf("\n\tImplementation of Kruskal's algorithm\n");
printf("\nEnter the no. of vertices:");
scanf("%d",&n);
printf("\nEnter the cost adjacency matrix:\n");
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
scanf("%d",&cost[i][j]);
if(cost[i][j]==0)
cost[i][j]=999;
}
}
printf("The edges of Minimum Cost Spanning Tree are\n");
while(ne < n)
{
for(i=1,min=999;i<=n;i++)
{
for(j=1;j <= n;j++)
{
if(cost[i][j] < min)
{
min=cost[i][j];
a=u=i;
b=v=j;
}
}
}
u=find(u);
v=find(v);
if(uni(u,v))
{
printf("%d edge (%d,%d) =%d\n",ne++,a,b,min);
mincost +=min;
}
cost[a][b]=cost[b][a]=999;
}
printf("\n\tMinimum cost = %d\n",mincost);
}
int find(int i)
{
while(parent[i])
i=parent[i];
return i;
}
int uni(int i,int j)
{
if(i!=j)
{
parent[j]=i;
return 1;
}
return 0;
}
2. Design and implement C/C++ Program to find Minimum Cost Spanning Tree of a given connected
undirected graph using Prim's algorithm.
#include<stdio.h>
#include<conio.h>
int i,j,u,v,n,ne=1;
int min,mincost=0,visited[10]={0},cost[10][10];
void main()
{
3. a) Design and implement C/C++ Program to solve All-Pairs Shortest Paths problem using Floyd's
algorithm.
#include<stdio.h>
#include<stdlib.h>
int a[10][10],d[10][10],n;
void path()
{
int i, j, k;
for(k=0;k<n;k++)
{
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
d[i][j]= min(d[i][j], d[i][k]+d[k][j]);
}
}
}
}
int main()
{
int i,j;
printf("Enter the no of Vertices:");
scanf("%d", &n);
printf("\nEnter the cost adjacency matrix:\n");
for(i=0;i<n;i++)
for(j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
d[i][j]= a[i][j];
}
path();
printf("Final Distance Matrix:\n");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
printf("%5d",d[i][j]);
}
printf("\n");
}
}
b) Warshal’s Algorithmn
#include<stdio.h>
#include<stdlib.h>
int a[10][10],t[10][10],n;
void path()
{
int i, j, k;
for(k=0;k<n;k++)
{
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if((t[i][j]) || (t[i][k]&& t[k][j]))
t[i][j] =1;
}
}
}
}
int main()
{
int i,j;
printf("Enter the no of Vertices:");
scanf("%d", &n);
printf("\nEnter the adjacency matrix:\n");
for(i=0;i<n;i++)
for(j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
t[i][j]= a[i][j];
}
path();
printf("Transitive Matrix:\n");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
printf("%5d",t[i][j]);
}
printf("\n");
}
}
4. Program in C to find shortest paths from a given vertex in a weighted connected graph to other vertices
using Dijkstra's algorithm.
#include<stdio.h>
#include<conio.h>
#define infinity 999
void dij(int n,int v,int cost[10][10],int dist[100])
{
int i,u,count,w,flag[10],min;
for(i=1;i<=n;i++)
flag[i]=0,dist[i]=cost[v][i];
count=2;
while(count<=n)
{
min=99;
for(w=1;w<=n;w++)
if(dist[w]<min && !flag[w])
min=dist[w],u=w;
flag[u]=1;
count++;
for(w=1;w<=n;w++)
if((dist[u]+cost[u][w]<dist[w]) && !flag[w])
dist[w]=dist[u]+cost[u][w];
}
}
int main()
{
int n,v,i,j,cost[10][10],dist[10];
printf("\n Enter the number of nodes:");
scanf("%d",&n);
printf("\n Enter the cost matrix:\n");
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
{
scanf("%d",&cost[i][j]);
if(cost[i][j]==0)
cost[i][j]=infinity;
}
printf("\n Enter the source matrix:");
scanf("%d",&v);
dij(n,v,cost,dist);
printf("\n Shortest path:\n");
for(i=1;i<=n;i++)
if(i!=v)
printf("%d->%d,cost=%d\n",v,i,dist[i]);
}
5. Design and implement C/C++ Program to obtain the Topological ordering of vertices in a given digraph.
#include<stdio.h>
#include<conio.h>
int a[10][10],n,indegre[10];
void find_indegre()
{ int j,i,sum;
for(j=0;j<n;j++)
{
sum=0;
for(i=0;i<n;i++)
sum+=a[i][j];
indegre[j]=sum;
}
}
void topology()
{
int i,u,v,t[10],s[10],top=-1,k=0;
find_indegre();
for(i=0;i<n;i++)
{
if(indegre[i]==0) s[++top]=i;
}
while(top!=-1)
{
u=s[top--];
t[k++]=u;
for(v=0;v<n;v++)
{
if(a[u][v]==1)
{
indegre[v]--;
if(indegre[v]==0) s[++top]=v;
}
}
}
printf("The topological Sequence is:\n");
for(i=0;i<n;i++)
printf("%d ",t[i]);
}
int main()
{
int i,j;
printf("Enter number of jobs:");
scanf("%d",&n);
printf("\nEnter the adjacency matrix:\n");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);
}
topology();
}
6. C/C++ Program to solve 0/1 Knapsack problem using Dynamic Programming method.
#include<stdio.h>
#include<conio.h>
int w[10],p[10],v[10][10],n,i,j,cap,x[10]={0};
int max(int i,int j)
{
return ((i>j)?i:j);
}
int knap(int i,int j)
{
int value;
if(v[i][j]<0)
{
if(j<w[i])
value=knap(i-1,j);
else
value=max(knap(i-1,j),p[i]+knap(i-1,j-w[i]));
v[i][j]=value;
}
return(v[i][j]);
}
int main()
{
int profit,count=0;
printf("\nEnter the number of elements\n");
scanf("%d",&n);
printf("Enter the profit and weights of the elements\n");
for(i=1;i<=n;i++)
{
printf("For item no %d\n",i);
scanf("%d%d",&p[i],&w[i]);
}
printf("\nEnter the capacity \n");
scanf("%d",&cap);
for(i=0;i<=n;i++)
for(j=0;j<=cap;j++)
if((i==0)||(j==0))
v[i][j]=0;
else
v[i][j]=-1;
profit=knap(n,cap);
i=n;
j=cap;
while(j!=0&&i!=0)
{
if(v[i][j]!=v[i-1][j])
{
x[i]=1;
j=j-w[i];
i--;
}
else
i--;
}
printf("Items included are\n");
printf("Sl.no\tweight\tprofit\n");
for(i=1;i<=n;i++)
if(x[i])
printf("%d\t%d\t%d\n",++count,w[i],p[i]);
printf("Total profit = %d\n",profit);
}
7. C/C++ Program to solve discrete Knapsack and continuous Knapsack problems using greedy
approximation method.
#include<stdio.h>
#include<stdlib.h>
int main()
{
float weight[50],profit[50],ratio[50],Totalvalue,temp,capacity,amount;
int n,i,j;
printf("Enter the number of items :");
scanf("%d",&n);
for (i = 0; i < n; i++)
{
printf("Enter Weight and Profit for item[%d] :\n",i);
scanf("%f %f", &weight[i], &profit[i]);
}
printf("Enter the capacity of knapsack :\n");
scanf("%f",&capacity);
for(i=0;i<n;i++)
ratio[i]=profit[i]/weight[i];
temp = weight[j];
weight[j] = weight[i];
weight[i] = temp;
temp = profit[j];
profit[j] = profit[i];
profit[i] = temp;
}
8. C Program to find a subset of a given set S = {sl , s2,.....,sn} of n positive integers whose sum is equal to a
given positive integer d.
#include<stdio.h>
#include<conio.h>
int s[10] , x[10],d ;
void sumofsub ( int , int , int ) ;
int main ()
{
int n , sum = 0 ;
int i ;
printf ( " \n Enter the size of the set : " ) ;
scanf ( "%d" , &n ) ;
printf ( " \n Enter the set in increasing order:\n" ) ;
for ( i = 1 ; i <= n ; i++ )
scanf ("%d", &s[i] ) ;
printf ( " \n Enter the value of d : \n " ) ;
scanf ( "%d" , &d ) ;
for ( i = 1 ; i <= n ; i++ )
sum = sum + s[i] ;
if ( sum < d || s[1] > d )
printf ( " \n No subset possible : " ) ;
else
sumofsub ( 0 , 1 , sum ) ;
}
void sumofsub ( int m , int k , int r )
{
int i=1 ;
x[k] = 1 ;
if ( ( m + s[k] ) == d )
{
printf("Subset:");
for ( i = 1 ; i <= k ; i++ )
if ( x[i] == 1 )
printf ( "\t%d" , s[i] ) ;
printf ( "\n" ) ;
}
else
if ( m + s[k] + s[k+1] <= d )
sumofsub ( m + s[k] , k + 1 , r - s[k] ) ;
if ( ( m + r - s[k] >= d ) && ( m + s[k+1] <=d ) )
{
x[k] = 0;
sumofsub ( m , k + 1 , r - s[k] ) ;
}
}
9. Design and implement C Program to sort a given set of n integer elements using Selection Sort method
and compute its time complexity. Run the program for varied values of n> 5000 and record the time taken
to sort. Plot a graph of the time taken versus n. The elements can be read from a file or can be generated
using the random number generator.
# include <stdio.h>
# include <stdlib.h>
# include <time.h>
for (i = 0; i < n-1; i++) // One by one move boundary of unsorted subarray
{
small = i; //minimum element in unsorted array
int main()
{
int n, a[1000],k;
clock_t st,et;
double ts;
printf("\n Enter How many Numbers: ");
scanf("%d", &n);
printf("\nThe Random Numbers are:\n");
for(k=1; k<=n; k++)
{
a[k]=rand();
printf("%d\t",a[k]);
}
st=clock();
selection(a,n);
et=clock();
ts=(double)(et-st)/CLOCKS_PER_SEC;
printf("\nSorted Numbers are: \n ");
for(k=1; k<=n; k++)
printf("%d\t", a[k]);
printf("\nThe time taken is %e",ts);
}
10. Design and implement C/C++ Program to sort a given set of n integer elements using Quick Sort method
and compute its time complexity. Run the program for varied values of n> 5000 and record the time taken
to sort. Plot a graph of the time taken versus n. The elements can be read from a file or can be generated
using the random number generator.
# include <stdio.h>
#include<stdlib.h>
# include <time.h>
11. Design and implement C/C++ Program to sort a given set of n integer elements using Merge Sort method
and compute its time complexity. Run the program for varied values of n> 5000, and record the time
taken to sort. Plot a graph of the time taken versus n. The elements can be read from a file or can be
generated using the random number generator.
# include <stdio.h>
# include <stdlib.h>
#include<time.h>
12. Design and implement C/C++ Program for N Queen's problem using Backtracking.
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int a[30],count=0;
int place(int pos)
{
int i;
for(i=1;i<pos;i++)
{
if((a[i]==a[pos])||((abs(a[i]-a[pos])==abs(i-pos))))
return 0;
}
return 1;
}
void print_sol(int n)
{
int i,j;
count++;
printf("\n\nSolution #%d:\n",count);
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
if(a[i]==j)
printf("Q\t");
else
printf("*\t");
}
printf("\n");
}
}
void queen(int n)
{
int k=1;
a[k]=0;
while(k!=0)
{
a[k]=a[k]+1;
while((a[k]<=n)&&!place(k))
a[k]++;
if(a[k]<=n)
{
if(k==n)
print_sol(n);
else
{
k++;
a[k]=0;
}
}
else
k--;
}
}
int main()
{
int i,n;
printf("Enter the number of Queens\n");
scanf("%d",&n);
queen(n);
printf("\nTotal solutions=%d",count);
}
VIVA QUESTIONS
1. What is an Algorithm?
Algorithm is a Step by step procedure to Solve a given problem for a finite number of input
producing finite number of output with desired output.
5. Define Space and Time Complexity? Among this which one is more prioritized?
Space Complexity is a measure of Amount of Space taken by a Program to finish its Execution.
Time Complexity is a measure of amount of time taken by a program to complte its Execution.
Depending Upon Application it is considered, EX:For Mobile or Handheld Devices, We give
Prefernce for both Space and time.
For a Huge and Inter active Systems like Web Applications we give more Preferences to time
Complexeity.
Analysis:Analysis is a next Phase of Writing an Algorithm ,in this phase we calculate the Efficiency
of anAlgorithm i.e time and space needed by an algorithm.
9. What is a Pseudocode?
It’s a notation which is having the combination of Programming Constructs and English like Statements.
10. What is the Time Complexity of Bubble Sort, Selection Sort , Merge Sort, Quick
Sort?(L3)
Bubble Sort-n2, Selection Sort- n2 Merge Sort-nlog.n Quick Sort -
nLogn, Worst case for Quick Sort- n2
14. For what type of instance Merge sort do better than Quick Sort?
15. For what type of instance Quick sort do better than Merge Sort?
17. Write the order of growth terms as per the time Execution in Ascending Order.
logn,n,nlogn,n2,n3, ...... nn,2n,n!
19. What is the difference between Divide and Conquer, Decrease and Conquer?
Divide and Conquer can be solved to solve a problem with a larger data set and when there
is no dependency between any of the data sets.
Divide and Solve as Small as Small sets.
Conquer or Merge it get one final resultant data set.
Decrease and Conquer is almost similar to Divide and Conquer but we are finding a
solutions to the problem in a different variations, EX:Decrease by Constant (Usually by
One),Decrease by Constant factor which is almost similar to Divide and Conquer
Technique(Usually by two),Decrease by Variable(The Dividing Criteria changes for each
iteration depends upon the data set.
Filling the Maximum number of items to the Knapsack (Container) Which Increases the
profit and decreases the Loss.
27. Differentiate between Prims and Kruskals Algorithm for finding MST.
In Prims We consider any one vertex in the graph as Source and We compute the distance
from that source to other vertices ,after computing the vertices which has minimum value
among (n-1) vertices is added to tree vertices and that respective edges added to tree Edges
Set.The above mentioned Process continues till we reach (n-1) vertices.
In Kruskals we first arrange the edges in Ascending Order and then we start to form the tree
which wont formcycles,if adding that edges forms cycles then that edges is dropped from adding
to tree edges.The above saidprocess is continues till we reach the count of
(n-1) Vertices.
32. What is the difference between Brute force strings matching to Horspool String Matching
Method? (L2)In brute Force we compare each and every element of the text to the pattern
by shifting the text position by one and in Horspool method we shift it by number of shift
positions recorded in the shift table.
34. What is the Basic Operations in Merge sort and Quick sort?
In Merge Sort the Basic Operations is Comparisions and in Quick sort basic Operations is
Partitioning and hence also known as partitioning sort.
DFS and BFS are both the Graph Traversing Technique,in which DFS Traverse the Graph
in a depth wise(Vertical) and BFS Traverse the Graph from left to right(Horizontal)
39. What are back edges in DFS and Cross Edges in BFS.
Back Edges and Cross edges are the Edges which already visited by a ancestor node.
42. What are the Different methods used to solve a topological Sorting ?
1.Source Removal Method
2.Using DFS based Scheme.
46. What are the different ways that can be represents a graph?
Adjaceny Matrix and Adjacency List.
Algorithm can't find the better the solutions when we come across the tight lower bound,
So we can find the better solutions which is not possible with Algorithmic way.To find the
Tight lower bound we use Decision Trees.