Tuesday 20 December 2011

Program to find average waiting and turn over time after sorting array


#include<iostream>
using namespace std;
class avg
{
 int a[10];
float w,tt,s,t,n;
public:
void read();
void display();
void awt();
void att();
void sort();
};
void avg::read()
{
        cout<<"enter no of members at theatre counter \n";
        cin>>n;
        cout<<"enter number of tickets want to purchase \n";
        for(int i=0;i<n;i++)
        {
        cout<<"a["<<i<<"]=";
        cin>>a[i];
        }
}
void avg::sort()
{
int x;
cout<<"before sorting\n";
        for(int i=0;i<n;i++)
        cout<<"a["<<i<<"]="<<a[i]<<"\t";
        cout<<"after sorting\n";
        for(int j=0;j<n-1;j++)
        {
        for(int i=0;i<n-j-1;i++)
        {
                if(a[i]>a[i+1])
                {
                x=a[i];
                a[i]=a[i+1];
                a[i+1]=x;
                }
        }
}
for(int i=0;i<n;i++)
        cout<<"a["<<i<<"]="<<a[i];
}
void avg::awt()
{       s=0;t=0;
        for(int i=0;i<n-1;i++)
        {
                s=s+a[i];
                t=t+s;
        }
cout<<"sum of awt is="<<t<<"\n";
        w=t/n;
}
void avg::att()
{
        t=0;s=0;
        for(int i=0;i<n;i++)
        {
                t=t+a[i];
                s=s+t;
        }
cout<<"sum of att is="<<s<<"\n";

        tt=s/n;
}
void avg::display()
{
        cout<<"no of tickets each person will purchase \n";
        for(int i=0;i<n;i++)
        cout<<"a["<<i<<"]="<<a[i];
cout<<"average waiting time is"<<w<<"\n";
        cout<<"average turn over time is"<<tt<<"\n";
}
int main()
{
        avg ob;
        ob.read();
        ob.sort();
        ob.awt();
        ob.att();
        ob.display();
return 0;
}

Program to find average waiting and turn over time


#include<iostream>
using namespace std;
class avg
{
 int a[10],s,t,n,w,tt;
public:
void read();
void display();
void awt();
void att();
};
void avg::read()
{
        cout<<"enter no of members at theatre counter \n";
        cin>>n;
        cout<<"enter number of tickets want to purchase \n";
        for(int i=0;i<n;i++)
        {
        cout<<"a["<<i<<"]=";
        cin>>a[i];
        }
}
void avg::awt()
{       s=0;t=0;
        for(int i=0;i<n-1;i++)
        {
                s=s+a[i];
                t=t+s;
        }
cout<<"sum of awt is="<<t<<"\n";
        w=t/n;
}
void avg::att()
{
        t=0;s=0;
        for(int i=0;i<n;i++)
        {
                t=t+a[i];
                s=s+t;
        }
cout<<"sum of att is="<<s<<"\n";

        tt=s/n;
}
void avg::display()
{
        cout<<"no of tickets each person will purchase \n";
        for(int i=0;i<n;i++)
        cout<<"a["<<i<<"]="<<a[i];
cout<<"average waiting time is"<<w<<"\n";
        cout<<"average turn over time is"<<tt<<"\n";
}
int main()
{
        avg ob;
        ob.read();
        ob.awt();
        ob.att();
        ob.display();
return 0;
}

Tuesday 13 December 2011

program for multiplication of two matrices by pointers

#include<stdio.h>
#include<stdlib.h>
int main()
{
    int **p,**q,**s;
    int m1,m2,n1,n2,i,j,k=0,sum;
    printf("enter oreder of 1st matrix:");
    scanf("%d%d",&m1,&n1);
    printf("Enter order of 2nd matrix:");
    scanf("%d%d",&m2,&n2);
    if(m1!=n2)
              printf("Multiplication not possible.");
    else
    {
        printf("Enter elements of 1st matrix:");
        p=malloc(m1*sizeof(int*));
        for(i=0;i<m1;i++)
                p[i]=malloc(n1*sizeof(int));
        for(i=0;i<m1;i++)
                for(j=0;j<n1;j++)
                        scanf("%d",&p[i][j]);
        printf("Enter elements of 2nd matrix:");
        q=malloc(m2*sizeof(int*));
        for(i=0;i<m2;i++)
                q[i]=malloc(m2*sizeof(int));
        for(i=0;i<m2;i++)
                for(j=0;j<n2;j++)
                        scanf("%d",&q[i][j]);
        printf("product is\n");
        s=malloc(m1*sizeof(int*));
        for(i=0;i<m1;i++)
                s[i]=malloc(n2*sizeof(int));
        for(i=0;i<m1;i++)
        {
                for(j=0;j<n2;j++)
                {
                        sum=0;
                        for(k=0;k<m1;k++)
                        {
                                sum=sum+p[i][k]*q[k][j];
                        }
                        s[i][j]=sum;
                        printf("%d ",s[i][j]);
                }
                printf("\n");
        }
}
}

program for addition of two matrices by pointers

#include<stdio.h>
#include<malloc.h>
main()
{
        int **a,**b,**c;
        int m,n,i,j;
        printf("\n enter the size of matrix (m*n): \n");
        scanf("%d %d",&m,&n);
        a = (int **)malloc(sizeof(int*)*m);
        for(i=0;i<m;i++)
                a[i] = (int *)malloc(sizeof(int)*n);
        b = (int **)malloc(sizeof(int*)*m);
        for(i=0;i<m;i++)
                b[i] = (int *)malloc(sizeof(int)*n);
        printf("\n enter the elements of first matrix: \n");
        for(i=0;i<m;i++)
                for(j=0;j<n;j++)
                        scanf("%d",&a[i][j]);
        printf("\n enter the lements of second matrix: \n");
        for(i=0;i<m;i++)
                for(j=0;j<n;j++)
                        scanf("%d",&b[i][j]);
        c = (int **)malloc(sizeof(int*)*m);
        for(i=0;i<m;i++)
                c[i] = (int *)malloc(sizeof(int)*n);
        for(i=0;i<m;i++)
                for(j=0;j<n;j++)
                        c[i][j]=a[i][j]+b[i][j];
        printf("\n the addition matrix is: \n");
                for(i=0;i<m;i++)
                {
                        printf("\n");
                        for(j=0;j<n;j++)
                                printf("%d ",c[i][j]);
                }

}

program for addition of two matrices

#include<stdio.h>
main()
{
        int a[10][10],b[10][10],c[10][10],m,n;
        int i,j;
        printf("\n enter the size of the matrix (m*n): ");
        scanf("%d %d",&m,&n);
        printf("\n enter the elements of first matrix: \n");
        for(i=0;i<m;i++)
                for(j=0;j<n;j++)
                        scanf("%d",&a[i][j]);
        printf("\n enter the lements of second matrix: \n");
        for(i=0;i<m;i++)
                for(j=0;j<n;j++)
                        scanf("%d",&b[i][j]);
        for(i=0;i<m;i++)
                for(j=0;j<n;j++)
                        c[i][j]=a[i][j]+b[i][j];
        printf("\n the addition matrix is: \n");
        for(i=0;i<m;i++)
        {
                printf("\n");
                for(j=0;j<n;j++)
                        printf("%d ",c[i][j]);
        }

}

program to add two integers using pointers

#include<stdio.h>
#include<malloc.h>
main()
{
        int *a,*b,c;
        a=(int*) malloc(sizeof(int));
        b=(int*) malloc(sizeof(int));
        printf("\n enter two numbers: ");
        scanf("%d %d",a,b);
        c=*a+*b;
        printf("\n the addition of the two numbers is %d",c);
}

program to add two integers

#include<stdio.h>
main()
{
 int a,b,sum;
 printf("enter 2 numbers a&b");
 scanf("%d%d",&a,&b);
 printf("entered numbers are a=%d & b=%d",a,b);
 sum=a+b;
 printf("sum is %d",sum);

}

Saturday 3 December 2011

B5(2/4) 4th sem time table


B5(2/4) 4th sem time table
TIMINGS :- AS 3RD SEM (9:00 - 12:30 & 2:00 - 4:30)
Mon: OS,CO,PPL,JAVA - COUNSELLING,SPORTS
Tue: MPI,CO,JAVA,OS - OS LAB (214)
Wed: PPL,MPI,EC,EC - MPI LAB (BATCH I)
Thus: MPI LAB (BATCH II) - JAVA,OS,MPI
Fri: CO,OS,EC,PPL - JAVA Lab (213)
Sat: PPL,MPI,JAVA,CO - LIBRARY

CO :- Smt.D.SUNEETHA
JAVA :- Sri A.PRAVEEN KUMAR
MPI :- Sri B.J.JAIDAN
OS :- Sri A.DIVAKAR
PPL :- Smt B.SOWJANYA
EC :- Sri K.V.R

MPI LAB (BATCH I) :- BJ +BS
MPI LAB (BATCH II) :- TSR+SKR
JAVA LAB :- APK+RS+MP+SVGR
OS LAB :- AD+AS+JH+NMK

Thursday 10 November 2011

B5,Tour Plan


SPECIALLY DESIGNED TOUR PROGRAME FOR
GITAM ENGINEERING COLLEGE STUDENTS
CSE –BRANCH-B5
AGRA-MATHURA-DELHI-SHIMLA-KUFRI-KULLU-MANALI-CHANDIGARAH-DELHI
DAY-1 Nov22nd –Arrival Delhi at 5: PM, Pick up from station, Transfer to Hotel,
                        Dinner AT (AP BHAVAN)
                        Night halt at Delhi. (HOTEL ASHOKA INTERNATIONAL)
DAY-2 Nov23rd - Breakfast, Dep for Agra AT 7:00 AM,
Arrival mathura 12:00noon Visiting Matura Temple Dep for Tajmahal   Visiting, Tajmahal, Agra fort
Dinner at agra Dep for Delhi Night halt at Delhi
DAY-3Nov24th Breakfast,
Sight seeing at Delhi
                        Lotus Temple, Birla mandir, India Gate, qutubminar,                                                     Rajghat, and many more places
                        Evening free for shopping
                        Dinner  at ( AP BHAVAN) 
Night halt at Delhi 
DAY-4 Nov25th –Hotel Check-out , Breakfast Visiting industry
                        Afternoon Dep for Chandigarah
                        Arrival Chandigarah at Evening, Hotel Check-in, Dinner,
Night Halt (HOTEL SHAGUN)
DAY-5Nov26th Breakfast Hotel Check-out
                        Visiting Industry
Half day sight seeing at Chandigarh.
Visiting Rock Garden, Rose Garden, Dinner
Night Dep for Manali
 DAY-6Nov27th Hotel Check-in, Breakfast at Visit Rohtang pass
 (Snow point) Visiting Hadimba temple, solang valley, vashisth Kund (Hot springs) Dinner
Night Halt at Manali (HOTEL PARKRESIDENCY)
DAY-7 Nov28th Breakfast, Visiting Water rafting, Kullu temple,
                        Dinner, Night halt
DAY-8 Nov29th Hotel Check-out , Dep for Shimla , Pass through Beas river , sutlez link project, Arrival shimla at evening , Hotel Checkin , Dinner
                        Night halt at shimla (HOTEL SATYAM PARADISE)
DAY-9Nov30th, Breakfast Hotel check-out
                        Sight seeing at Shimla
                        Visit Kufri – Winter sports Capital, Indira Bungalow and
Other places of tourist importance.Dinner
Evening Dep for Delhi

DAY-10Dec1st dropping at railway Station at 6:00 AM  
           
PACKAGE INCLUDES
Local Travel by Hi-tech non a/c  Buses (2X2 Buses push back)
Accommodation in good 2 STAR AND 3 STAR hotels at 4 sharing basis (incTV, hot water and phone facility)
Industry Permissions.
Faculty members as complimentary
Food Breakfast and dinner (North Indian veg )
PACKAGE EXCLUDES

Lunch  Train tickets, Entry tickets, Pony charges , sumo Charges and other miscellaneous expenditure which are not mentioned

NOTE;- FOOD COULD NOT BE PROVIDED IN TRAINS

Thanking you and assuring you our best services at all Times

With Regards,
 Amjad
(Tour Co-coordinator)
Ph: 09246570327      
For Hotel details please go through our website www.primeindustrialtour.com

Wednesday 26 October 2011

Industrial Tour Letter


http://www.mediafire.com/?cft0sdcxytuf3lc



Download Industrial Letter  And Submit it To Mahesh or Pranathi

Monday 24 October 2011

Program on Hashing Chain



#include<iostream>
#include<cstdlib>
using namespace std;
class hashch
{
      struct node
      {
             int value;
             node *link;
      };
     public:
            struct node *hashtable[10];
            void insert(int);
            void del(int);
            bool search(int);
            void display();
            void inp();

};
void hashch::inp()
{
 for(int i=0;i<10;i++)
     {
                      hashtable[i]=NULL;
     }
}
void hashch::insert(int val)
{
     int c,i;

     node *t;
     t=new node;
     t->value=val;
     t->link=NULL;
     c=val%10;
     if(hashtable[c]==NULL)
           hashtable[c]=t;
     else
     {
         node*p;
         p=new node;
         p=hashtable[c];
         if(val<p->value)
         {
                       t->link=p;
                       hashtable[c]=t;
         }
         else
         {
             while (val>p->link->value&&p->link!=NULL)
             p=p->link;
             if(p->link->link!=NULL)
            {
                t->link=p->link;
                p->link=t;
             }
             else if(val<p->link->value)
             {
                  t->link=p->link;
                  p->link=t;
             }
             else
             p->link->link=t;
         }
     }
}
void hashch::del(int val)
{
     int c;
     node *t,*p ;
     c=val%10;
     t=new node;
     p=new node;

     if(hashtable[c]!=NULL)
     {
                          if(t->value==val)
                          {
                            t=hashtable[c];
                            hashtable[c]=hashtable[c]->link;
                           delete t;
                          }
                          else
                          {
                                  p=hashtable[c];
                                  while(p->link->link!=NULL&&p->link->value!=val)
                                  {
                                       p=p->link;

                                  }
                                  if(t->link->link!=NULL)
                                  {
                                                          t=p->link;
                                                          p->link=p->link->link;
                                                          free(t);
                                  }
                                   else
                                   t->link=NULL;
                          }
}
                          else
                          cout<<"\nThe bucket doesnt exist\n";
}

bool hashch::search(int val)
{
     int c;
     node *t;
     c=val%10;
     t=hashtable[c];
     if(hashtable[c]!=NULL)
     {
                           while(t!=NULL)
                           {
                                         if(t->value==val)
                                         {
                                                          cout<<"Found\n";
                                                          return true;
                                         }
                                         else
                                         {
                                             t=t->link;
                                         }
                           }


                               cout<<"The value doesnt exist\n";
                                return false;

     }
     else
     cout<<"The bucket is empty\n";
}
void hashch::display()
{
    node *p[10];
   node *t;

     int i;
    for(i=0;i<10;i++)
{
     p[i]=hashtable[i];
}
    for(i=0;i<10;i++)
    {
             t=new node;
                     if(p[i]!=NULL)
                     {
                                   t=p[i];
                                    while(t!=NULL)
                                   {

                                   cout<<t->value<<"\t";
                                    t=t->link;
                                    }
                     cout<<"\n";
                     }
                     else
                     cout<<"NULL\n";
      }
}
int main()
{
    hashch ch;
    int option;
    int ele;

    bool ans;
    ch.inp();
    while(1)
    {
            cout<<"\nEnter your choice\n";
            cout<<"\n1.Insert\n2.Delete\n3.Search\n4.Display\n5.Exit\n";
            cin>>option;
            switch(option)
            {
                          case 1:cout<<"\nEnter what you want to insert\n";
                          cin>>ele;
                          ch.insert(ele);
                               break;
                          case 2:cout<<"\nEnter what you want to delete\n";
                               cin>>ele;
                               ch.del(ele);
                                break;
                          case 3:cout<<"\nEnter what you want to search\n";
                                 cin>>ele;
                                 ans=ch.search(ele);
                                 if(ans)
                                  cout<<"\nFound\n";
                                 else
                                  cout<<"\nMissing\n";
                                 break;
                          case 4: ch.display();
                                  break ;
                          case 5: exit(1);
            }
    }
    return 0;

}




OUTPUT:-

Enter your choice

1.Insert
2.Delete
3.Search
4.Display
5.Exit
1

Enter what you want to insert
2

Enter your choice

1.Insert
2.Delete
3.Search
4.Display
5.Exit
3

Enter what you want to search
2
Found

Found

Enter your choice

1.Insert
2.Delete
3.Search
4.Display
5.Exit
1

Enter what you want to insert
4

Enter your choice

1.Insert
2.Delete
3.Search
4.Display
5.Exit
4
NULL
NULL
2
NULL
4
NULL
NULL
NULL
NULL
NULL

Enter your choice

1.Insert
2.Delete
3.Search
4.Display
5.Exit
1

Enter what you want to insert
6

Enter your choice

1.Insert
2.Delete
3.Search
4.Display
5.Exit
4
NULL
NULL
2
NULL
4
NULL
6
NULL
NULL
NULL

Enter your choice

1.Insert
2.Delete
3.Search
4.Display
5.Exit

Program on add and multiplication of Polynomials


#include<iostream>
using namespace std;
#define n 100
class poly
{
 private:
                int a[n], b[n], add[n], mul[n], p, q, at;
        public:
                void init ( );
void input ( );
                void process ( );
                void display ( );
};
void poly :: init ( )
{
        int i;
        for( i = 0; i < n; i++)
                a[ i ] = b [ i ] = add[ i ] = mul[ i ] = 0;
}
void poly :: input ( )
{
        int i;
    cout<<"\nEnter Degree Of First Polynomial::";
        cin>>p;
        cout<<"\nEnter Degree Of Second Polynomial::";
        cin>>q;
        cout<<"\nEnter Values in First Polynomial\n";
        for( i = 0; i <= p; i++)
        {
                cout<<"\nEnter X^"<<i<<" The Coefficient";
                cin>>a[ i ];
        }
        cout<<"\nEnter Values in Second Polynomial\n";
        for( i = 0; i <= q; i++)
        {
                cout<<"\nEnter X^"<<i<<" The Coefficient";
                cin>>b[ i ];
        }
}
void poly :: process ( )
{
        int i, j;
        if( p > q )
                at = p;
        else
                at = q;
        for ( i = 0; i <= at;i++   )
                add[ i ] = a[ i ] + b[ i ];
                for( i = 0;  i <= p;  i++)
                        for( j = 0; j <= q; j++)
                                  mul[i+j]+= a[i]*b[j];
}
void poly :: display ( )
{
 int i;
cout<<"Addition Of Two Polynomial Expressions Are\n\n";
for( i = at; i >=0 ; i--)
cout<<add[i]<<"X^"<<i<<"+";
cout<<"\n\nMultiplication Of Two Polynomial Expressions Are\n\n";
for( i = p + q; i >= 0; i--)
cout<<mul[i]<<"X^"<< i <<"+";
}
int main()
{
poly ob;
ob.init ( );
ob.input ( );
ob.process ( );
ob.display ( );
return 0;
}


OUTPUT:-

Enter Degree Of First Polynomial::2

Enter Degree Of Second Polynomial::2

Enter Values in First Polynomial

Enter X^0 The Coefficient1

Enter X^1 The Coefficient2

Enter X^2 The Coefficient5

Enter Values in Second Polynomial

Enter X^0 The Coefficient6

Enter X^1 The Coefficient4

Enter X^2 The Coefficient7
Addition Of Two Polynomial Expressions Are

12X^2+6X^1+7X^0+

Multiplication Of Two Polynomial Expressions Are

35X^4+34X^3+45X^2+16X^1+6X^0+

Program on Graph Traversal


#include<iostream>
using namespace std;
class graphtraversal
{
        public:
                int size;
                int **adj;
                void readadj();
                void dfs();
                void bfs();
};
void graphtraversal::readadj()
{
        cout<<"enter no of vertices\n";
        cin>>size;
        adj=new int *[size];
        for(int i=0;i<size;i++)
                adj[i]=new int [size];
        cout<<"enter adj matrix:\n";
        for(int i=0;i<size;i++)
                for(int j=0;j<size;j++)
                        cin>>adj[i][j];
}
void graphtraversal::dfs()
{
        int stack[size],top=-1;
        int start,visited[size];
        for(int i=0;i<size;i++)
                visited[i]=0;
        cout<<"enter starting node:\n";
        cin>>start;
        stack[++top]=start;
        visited[start]=1;
        while(top!=-1)
        {
                start=stack[top--];
                cout<<start<<"  ";
                for(int i=0;i<size;i++)
                {
                        if(adj[start][i]==1 && visited[i]!=1)
                        {
                                stack[++top]=i;
                                visited[i]=1;
                        }
                }
        }
}
void graphtraversal::bfs()
{
        int queue[size],f=-1,r=0;
        int strt,visited[size];
        for(int i=0;i<size;i++)
                visited[i]=0;
        cout<<"enter starting node\n";
        cin>>strt;
        queue[r++]=strt;
        visited[strt]=1;
        while(f!=r-1)
        {
                strt=queue[++f];
                cout<<strt<<" ";
                for(int i=0;i<size;i++)
                {
                        if(adj[strt][i]==1 && visited[i]!=1)
                        {
                                queue[r++]=i;
                                visited[i]=1;
                        }
                }
        }
}
int main()
{
        graphtraversal ob;
        int op,n=1;
        while(n==1)
        {
                cout<<"\nenter the option\n";
                cout<<"1.read adj\n2.DFS\n3.BFS\n4.exit\n";
                cin>>op;
                switch(op)
                {
                        case 1:
                                ob.readadj();
                                break;
                        case 2:
                                ob.dfs();
                                break;
                        case 3:
                                ob.bfs();
                                break;
                        case 4:
                                n=0;
                                break;
                }
        }
}


OUTPUT:-

enter the option
1.read adj
2.DFS
3.BFS
4.exit
1
enter no of vertices
4
enter adj matrix:
0
^Z
[4]+  Stopped                 ./a.out
[b520@localhost ~]$ ./a.out

enter the option
1.read adj
2.DFS
3.BFS
4.exit
1
enter no of vertices
4
enter adj matrix:
0 0 1 0
1 0 0 0
0 0 0 1
0 1 0 0

enter the option
1.read adj
2.DFS
3.BFS
4.exit
2
enter starting node:
0
0  2  3  1
enter the option
1.read adj
2.DFS
3.BFS
4.exit
3
enter starting node
0
0 2 3 1
enter the option
1.read adj
2.DFS
3.BFS
4.exit
4



Program on Hashing


#include<iostream>
#include<cstdlib>
using namespace std;
class ihash
{
      int *p;
      int d;
      public:
             ihash()
             {
                    d=10;
                    }
                    void insert(int);
                    bool search(int);
                    void del(int);
                    void display();
                    void inp();
};
void ihash::inp()
{
     p=new int[10];
     for(int i=0;i<10;i++)
       p[i]=-1;
}

void ihash::insert(int key)
{

     int i;
     i=key%d;
     if(p[i]==-1)
       p[i]=key;
       else
       {
           int j=i;
            i=(i+1)%d;
            while(i!=j)
            {
                       if(p[i]==-1)
                       {
                           p[i]=key;
                           break;
                           }
                        else
                        i=(i+1)%d;
            }
}
}
bool ihash::search(int key)
{
     int i,j;
     i=key%d;
     if(p[i]==key)
       return true;
     else
     {
         j=i;
         i=(i+1)%d;
         while(i!=j)
         {
                    if(p[i]==key)
                    return key;
                    else
                    i=(i+1)%d;
         }
         return false;
     }
}
void ihash::del(int key)
{
     int i,j;
     i=key%d;
     if(p[i]==key)
       p[i]=-1;
     else
     {
         j=i;
         i=(i+1)%d;
         while(i!=j)
         {
                    if(p[i]==key)
                      p[i]=-1;
                    else
                     i=(i+1)%d;
         }
     }

}
void ihash::display()
{
     for(int i=0;i<10;i++)
     {
             if(p[i]==-1)
             cout<<"NULL\n";
             else
             cout<<p[i]<<"\n";
             }
             }
int main()
{
    int option;
    bool ans;
    int key;
    ihash ih;
      ih.inp();

    while(1)
    {


            cout<<"\nEnter your choice\n";
            cout<<"\n1.Insert\n2.Delete\n3.Search\n4.Display\n5.Exit\n";
            cin>>option;
            switch(option)
            {
                          case 1:cout<<"\nEnter the value your want to insert\n";
                                 cin>>key;
                                 ih.insert(key);
                                 break;
                          case 2:cout<<"\nEnter the value you want to delete\n";
                                 cin>>key;
                                 ih.del(key);
                                 break;
                          case 3:cout<<"\nEnter the value you want to search\n";
                                 cin>>key;
                                 ans=ih.search(key);
                                 if(ans)
                                  cout<<"\nFound\n";
                                  else
                                  cout<<"\nMissing\n";
                                 break;
                          case 4:ih.display();
                                  break;
                          case 5:exit(1);
            }
    }
return 0;
}


OUTPUT:-

Enter your choice

1.Insert
2.Delete
3.Search
4.Display
5.Exit
1

Enter the value your want to insert
2

Enter your choice

1.Insert
2.Delete
3.Search
4.Display
5.Exit
1

Enter the value your want to insert
4

Enter your choice

1.Insert
2.Delete
3.Search
4.Display
5.Exit
1

Enter the value your want to insert
6

Enter your choice

1.Insert
2.Delete
3.Search
4.Display
5.Exit
4
NULL
NULL
2
NULL
4
NULL
6
NULL
NULL
NULL

Enter your choice

1.Insert
2.Delete
3.Search
4.Display
5.Exit
3

Enter the value you want to search
4

Found

Enter your choice

1.Insert
2.Delete
3.Search
4.Display
5.Exit
2

Enter the value you want to delete
6

Enter your choice

1.Insert
2.Delete
3.Search
4.Display
5.Exit
4
NULL
NULL
2
NULL
4
NULL
NULL
NULL
NULL
NULL

Enter your choice

1.Insert
2.Delete
3.Search
4.Display
5.Exit
5

Sunday 23 October 2011

Program for Quick Sort


#include<iostream>
#include<cstdlib>
using namespace std;
class sort
{
        int a[20],b[20];
        int low,high;
        public:
                int n;
                int get();
                void getdata();
                void quicksort(int,int);
                void display();

};
void sort::getdata()
{
        cout<<"enter the number of elements in the array";
        cin>>n;
        cout<<"enter the elements";
        for(int i=0;i<n;i++)
                cin>>b[i];
}
int sort::get()
{
   return n;
}
void sort::quicksort(int low,int high)
{
    int p,i,j,t;
    p=i=low,j=high;
    if(i<j)
    {
       while(i<j)
       {
          while(b[p]<b[j])
            j--;
            if(b[p]>b[j])
              {
                 t=b[p];
                 b[p]=b[j];
                 b[j]=t;
                 p=j;
              }
                while(b[p]>b[i])
                    i++;
                   if(b[p]<b[i])
                   {
                        t=b[i];
                        b[i]=b[p];
                        b[p]=t;
                        p=i;
                   }
                        if(i>=j)
                         {
                             quicksort(low,i-1);
                             quicksort(i+1,high);
                         }
        }
     }
}
void sort::display()
{
        cout<<"the sorted list is\n";
        for(int i=0;i<n;i++)
                                               {
                cout<<b[i]<<"\t";
        }
}
int main()
{
        sort a;
        int op;
        while(1)
        {
                cout<<"enter the option\n";
                cout<<"1.get data\n2.quick sort\n3.display\n4.exit\n";
                cin>>op;
                switch(op)
                {
                        case 1:
                                a.getdata();
                                break;
                        case 2:
                                a.get();
                                a.quicksort(0,a.n-1);
                                break;
                        case 3:
                                a.display();
                                break;
                        case 4:
                                exit(1);
                }
        }
}


OUTPUT:-

enter the option
1.get data
2.quick sort
3.display
4.exit
1
enter the number of elements in the array5
enter the elements2
1
3
6
7
enter the option
1.get data
2.quick sort
3.display
4.exit
3
the sorted list is
2       1       3       6       7       enter the option
1.get data
2.quick sort
3.display
4.exit
2
enter the option
1.get data
2.quick sort
3.display
4.exit
3
the sorted list is
1       2       3       6       7       enter the option
1.get data
2.quick sort
3.display
4.exit
4


Program for Linear search and Binary search


#include<iostream>
#include<cstdlib>
using namespace std;
class search
{
        int arr[10];
        public:
        bool linearsearch(int);
        bool binarysearch(int);
        void sort();
        void readarray();
};
bool search::linearsearch(int ele)
{
        for(int i=0;i<10;i++)
                if(arr[i]==ele)
                        return true;
        return false;
}
bool search::binarysearch(int ele)
{
        int low=0,high=9,mid;
        search ob;
        ob.sort();
        while(low<=high)
        {
                mid=(low+high)/2;
                if(ele==arr[mid])
                        return true;
                else if(ele<arr[mid])
                        high=mid-1;
                else
                        low=mid+1;
        }
        return false;
}
void search::sort()
{
        for(int i=0;i<9;i++)
                for(int j=0;j<9;j++)
                        if(arr[j]>arr[j+1])
                        {
                                int temp=arr[j];
                                arr[j]=arr[j+1];
                                arr[j+1]=temp;
                        }
}
void search::readarray()
{
        cout<<"Enter the elements of the array:";
        for(int i=0;i<10;i++)
                cin>>arr[i];
}
int main()
{
        search ob;
        int ele,choice;
        bool b;
        ob.readarray();
        cout<<"Enter the element to be found:";
        cin>>ele;
        cout<<"Which search would you like to use?\n\n1.Linear Search\n2.Binary search\n";
        cin>>choice;
        switch(choice)
        {
                case 1:
                        {
                        b=ob.linearsearch(ele);
                        if(b==true)
                                cout<<"Element found.";
                        else
                                cout<<"Element not found.";
                        }
                break;
                case 2:
                        {
                        b=ob.binarysearch(ele);
                        if(b==true)
                                cout<<"Element found.";
                        else
                                cout<<"Element not found.";
                        }
                break;
        }
}


OUTPUT:-


Enter the elements of the array:2
1
4
6
2
3
1
4
5
6
Enter the element to be found:5
Which search would you like to use?

1.Linear Search
2.Binary search
1
Element found.

B5 Tour Plan


SPECIALLY DESIGNED TOUR PROGRAME FOR
GITAM ENGINEERING COLLEGE STUDENTS
CSE –BRANCH-B5 
AGRA-MATHURA-DELHI-SHIMLA-KUFRI-KULLU-MANALI-CHANDIGARAH-DELHI
DAY-1 Nov22nd –Arrival Delhi at 6: PM, Pick up from station, Transfer to Hotel,
                            Night halt at Delhi. (HOTEL ASHOKA INTERNATIONAL)
DAY-2 Nov23rd -in Breakfast, Dep for Agra
     Visiting AKSHARDHAM TEMPLE
                       COSMO  INFORMATICS PVT LTD    visit Tajmahal, Agra fort
                        Evening Visiting Mathura
 Visiting industry TRANSOFT INFOTECH Night halt at Agra
DAY-2 Nov24th Breakfast, Visiting Indistry HCL
Half day Sight seeing at Delhi
                        Lotus Temple, Birla mandir, India Gate, qutubminar,                                                     Rajghat, and many more places
Dinner   VISITING INDUSTRY  NEWGEN SOFTWARE TECHNOLOGIES LTD
Night halt at Delhi 
DAY-3 Nov25th –Breakfast Half day sight seeing, 
                        Afternoon Dep for Chandigarah
                        Arrival Chandigarah at Evening, Hotel Check-in, Dinner,
Night Halt  
DAY-4Nov26th Breakfast Hotel Check-out
                        Visiting Industry  PARAMOUNT GRAPHICS PVT LTD
Half day sight seeing at Chandigarh.
Visiting Industry SPIC MICROSOFT PVT LTD
Rock Garden, Rose Garden
Night Dep for Manali
 DAY-5 Nov27th Hotel Check-in, Breakfast at Visit Rohtang pass
 (Snow point) Visiting Hadimba temple, solang valley, vashisth Kund (Hot springs)
Night Halt at Manali ( HOTEL APPLE GREEN MANALI)
DAY-6 Nov28th Breakfast, Visiting Water rafting, Kullu temple,
                        Dinner, Night halt
DAY-7 Nov29th Hotel Check-out , Dep for Shimla , Pass through Beas river , sutlez link project, Arrival shimla at evening , Hotel Checkin , Dinner
                        Night halt at shimla (HOTEL SATYAM PARADISE)
DAY-8 Nov30th, Breakfast Hotel check-out
Sight seeing at Shimla VISITING INDUSTRY  (STPI(Software Technology  Parks of India)

                        Visit Kufri – Winter sports Capital, Indira Bungalow and
Other places of tourist importance.
Evening Dep for Delhi at 4:00 PM
                       

DAY-10Dec1st  Dropping at railway Station at 6:00 AM 

Saturday 22 October 2011

Program on Merge Sort


#include<iostream>
#include<cstdlib>
using namespace std;
class array
{
      int a[10],n,b[10];
      public:
             void create(int n);
             void display(int n);
             void sort(int low,int high);
             void mergesort(int low,int mid,int high);

};
void array::create(int n)
{

     cout<<"the elements are:\n";
     for(int i=0;i<n;i++)
     cin>>a[i];
}
void array::display(int n)
{
     for(int i=0;i<n;i++)
     cout<<a[i]<<endl;
}
void array::sort(int low,int high)
{
     if(low<high)
     {
        int mid=(low+high)/2;
        sort(low,mid);
        sort(mid+1,high);
        mergesort(low,mid,high);
     }
}
void array::mergesort(int low,int mid,int high)
{
     int h=low,k=0;
     int i=low;
     int j=mid+1;
     while(h<=mid&&j<=high)
     {
         if(a[h]<a[j])
                b[k++]=a[h++];
         else
                b[k++]=a[j++];
     }
     while(h<=mid)
     {
         b[k++]=a[h++];

     }
       while(j<=high)
            b[k++]=a[j++];
            j=0;
        for(int k=low;k<=high;k++)
        a[k]=b[j++];
}
int main()
{
    array a;
    int n;
    cout<<"the no.of elements in array are:\n";
    cin>>n;
    a.create(n);
    cout<<"the given array is:\n";
    a.display(n);
    int low=0;
    int high=n-1;
    a.sort(low,high);
    cout<<"the sorted array is:\n";
    a.display(n);
    return 0;
}


OUTPUT:-

the no.of elements in array are:
5
the elements are:
1
6
8
2
3
the given array is:
1
6
8
2
3
the sorted array is:
1
2
3
6
8

Program on Selection Sort


#include<iostream>
#include<cstdlib>
using namespace std;
class sort
{
        int a[20];
        int n,t;
        public:
                void getdata();
                void selectionsort();
                void display();
};
void sort::getdata()
{
        cout<<"enter the number of elements in the array\n";
        cin>>n;
        cout<<"enter the elements\n";
        for(t=0;t<n;t++)
                cin>>a[t];
}
void sort::selectionsort()
{
        int small;
        for(int i=0;i<n-1;i++)
        {
                small=i;
                for(int j=i+1;j<n;j++)
                {
                        if(a[small]>a[j])
                        small=j;
                }
                int temp=a[i];
                a[i]=a[small];
                a[small]=temp;
        }
}
void sort::display()
{
        cout<<"the sorted list is\n";
        for(int i=0;i<n;i++)
        {
                cout<<a[i]<<"\t";
        }
}
int main()
{
        sort ob;
        int op;
        while(1)
        {
                cout<<"\nenter the option\n";
                cout<<"1.get data\n2.selection sort\n3.display\n4.exit\n";
                cin>>op;
                switch(op)
                {
                        case 1:
                                ob.getdata();
                                break;
                        case 2:
                                ob.selectionsort();
                                break;
                        case 3:
                                ob.display();
                                break;
                        case 4:
                                exit(1);
                }
        }
}



OUTPUT:-

enter the option
1.get data
2.selection sort
3.display
4.exit
1
enter the number of elements in the array
5
enter the elements
1
6
5
2
3

enter the option
1.get data
2.selection sort
3.display
4.exit
2

enter the option
1.get data
2.selection sort
3.display
4.exit
3
the sorted list is
1       2       3       5       6
enter the option
1.get data
2.selection sort
3.display
4.exit
4