DFS tree in C++

#include#includeint cost[10][10],i,j,k,n;int stack[10],top,v,visit[10],visited[10];void main(){clrscr();int m;cout <<"Enter no of vertices\Nodes: ";cin >> n;cout <<"\nEnter no of Edges: ";cin >> m;cout <<"\n\tEnter All EDGES Source & Distination\n";for(k=1;k<=m;k++){cout<<"\nEnter Source: ";cin >>i;cout<<"\nEnter Distination: ";cin>>j;cost[i][j]=1;cout<<"\n———————–\n";}cout <<"\nEnter initial vertex: ";cin >>v;cout <<"\nORDER OF VISITED VERTICES:\n";cout <<v<<" ";visited[v]=1;k=1;while(k<n){for(j=n;j>=1;j–)if(cost[v][j]!=0 && visited[j]!=1 && visit[j]!=1){visit[j]=1;stack[top]=j;top++;}v=stack[–top];cout<<v << " ";k++;visit[v]=0;visited[v]=1;}getch();}

Data Structure Programs

“All Data Structure Programs up-till now” To get code Click on that program heading 🙂 ☺ ☻   ALL Type Of Sorting : Click here :: most important ::  ——————- TREES:-   RED AND BLACK TREE IN C++Insertion- Deletion- Searching -Max,Min Tree C++ Code Tree Non Liner Data Structure    Insert 100 in all Leaf nodes and 10 in all nonContinue reading “Data Structure Programs”