Google Search

Wednesday, October 27, 2010

DEPTH FIRST SEARCH program

/* DEPTH FIRST SEARCH */

#include
int x=1,a;
template
class depth
{
public:
T n,d[10][10],i,j,c[10];
void makenull()
{
int d;
for(d=0;d>n;
cout<<"\nEnter 0 if edge between the nodes else enter 0\n"; for(i=0;i>d[i][j];
}
}
void dfs(int b)
{
c[b]=1;
cout<>x;
}
};
main()
{
depth w;
w.getinput();
while(x==1)
{
cout<<"\nEnter the starting node of search\t"; cin>>a;
w.makenull();
cout<<"\nVisited node sequence is:\n";
w.dfs(a-1);
w.out();
}
cout<<"\nExiting Program\n";
}

0 comments:

Post a Comment