Posts

Showing posts from November, 2014
//Graph Colouring // Program for Graph Coloring using Backtracking. #include<iostream.h> #include<conio.h> #include<stdio.h> #include<process.h> class GraphColor {     int X[10],m,G[10][10],N;     public:         void GetData();         int NextValue(int);         void Mcoloring(int); }; void GraphColor :: GetData() {     cout << "\n Enter the numbers of nodes : ";     cin >> N;     cout << "\n Enter Graph : \n";     for(int i=1;i<=N;i++)     {         for(int j=1;j<=N;j++)         {             cin >> G[i][j];             X[j]=0;         }     } ...
//N-Queen #include<iostream.h> #include<conio.h> #include<math.h> class NQueen {     int i, X[10],k,count,N;     public:         NQueen()         {             k=1;             count=1;       //        N=8;             X[k]=0;         }         void Nqueen(void);         int Place(int); }; void NQueen :: Nqueen(void) {     cout << "\n Enter the numbers of queens :";     cin >> N;     while(k>0)     {         X[k]++;         while(X[k] <= N && Place(k) == 0)  ...
Design & Analysis of Algorithm Programs : USING RECURSION //Mazimum element using recursion #include<iostream.h> #include<conio.h> class Max {  int No,A[10],N,i,j,k;  public:   void Get();   int Maximum(int);   void Put(); }; void Max :: Get() {  cout << "\n Enter the size of array : ";  cin >> N;  cout << "\n Enter the elements :\n ";  for(int m=1;m<=N;m++)  {   cin >> A[m];  } } int Max :: Maximum(int i) {  if(i<N)  {   j=Maximum(i+1);   if(A[i] > A[j])   {    k=i;   }   else   {    k=j;   }  }  else  {   k=N;  }  return(k); } void Max :: Put() {  int ans = Maximum(1);  cout << "\n Maximum element is : " << A[ans]; } void main() {  Max m;  clrscr();  m.Get();  m....