Saturday 16 August 2014

Second Year Engineering SEM-III Practicals..




Second Year Engineering SEM-III Practicals..

First of all get linux on your window system
i know guyzz.....
till now we were habitual too use window platform in our day-to-day 
 but does it is secure ask too yourself..........??
soo now............
don't change your habit and get the linux platform on your window by this software..

VMWARE

VIRTUALBOX.

It is recommended by university to perform the practical on LINUX platform

SEM-1

------------------------------------------------------------------------------------------
DSPS(Data Structure And Problem Solving) Program's :
-------------------------------------------------------------------------------------------
DSPS Manual
GroupA

//============================================================================
// Author: Aman Bohra
//        ( bohraaman.blogspot.in)
// ROLL NO     : 007
// CLASS       : SE(COMPUTER)
// BATCH       : S1
// ASSIGNMENT NO.: 01
/* TITLE   :A Vegetable and Fruit Mall wants to organize its vegetables and fruit products in a combination of purchase
        pattern of customers. Solve the problem by suggesting appropriate data structures. Design necessary class.
//============================================================================*/ 

#include<iostream>
#include<string.h>
#include<stdio.h>

using namespace std;

class fruit
{
   public:
   int i,n,m[10],temp;
   char s[20][20],temp1[20][20];
    int getdata();
    int putdata();
};

class veg
{
 public:
   int i,n1,m1[10],temp;
   char s1[20][20],temp1[20][20];
    int getdata1();
    int putdata1();
};

int fruit::getdata()
{
 cout<<"\nEnter the number of fruits: ";
 cin>>n;
 for(i=0;i<n;i++)
 {
  cout<<"\nEnter the name: ";
  cin>>s[i];
  cout<<"Enter the quantity: ";
  cin>>m[i];
 }
return 0;
}

int fruit::putdata()
{
 cout<<"\nFruits          Amount";
 cout<<"\n....................";
  for(i=0;i<n;i++)
  {
  for(int j=1;j<n;j++)
  {
  if(m[i]<m[i+1])
  {
  temp=m[i];
  strcpy(temp1[i],s[i]);
  m[i]=m[i+1];
  strcpy(s[i],s[i+1]);
  m[i+1]=temp;
 strcpy(s[i+1],temp1[i]);
  }
  }
  }
  for(i=0;i<n;i++)
  {
  cout<<endl;
   cout<<s[i];
   cout<<"            "<<m[i];
  }
return 0;
}

int veg::getdata1()
{
  cout<<"\nEnter the number of vegetables: ";
 cin>>n1;
 for(i=0;i<n1;i++)
 {
  cout<<"\nEnter the name:";
  cin>>s1[i];
  cout<<"Enter the quantity: ";
  cin>>m1[i];
 }
return 0;
}

int veg::putdata1()
{
cout<<"\nVegetable          Amount";
 cout<<"\n....................";
  for(i=0;i<n1;i++)
  {
  for(int j=1;j<n1;j++)
  {
  if(m1[i]<m1[i+1])
  {
  int temp;
  temp=m1[i];
   strcpy(temp1[i],s1[i]);
  m1[i]=m1[i+1];
  strcpy(s1[i],s1[i+1]);
  m1[i+1]=temp;
  strcpy(s1[i+1],temp1[i]);
  }
  }
  }
  for(i=0;i<n1;i++)
  {
  cout<<endl;
   cout<<s1[i];
   cout<<"            "<<m1[i];
  }
  cout<<endl;

return 0;
}

 int main()
 {

  veg v;
  fruit f;
  f.getdata();
  v.getdata1();
  f.putdata();
  v.putdata1();
  return 0;
 }



//============================================================================
// Author: Aman Bohra
//        ( bohraaman.blogspot.in)
// ROLL NO     : 007
// CLASS       : SE(COMPUTER)
// BATCH       : S1
// ASSIGNMENT NO.: 02
/* TITLE   :A Dictionary stores keywords & its meanings. Provide facility for adding new keywords, deleting keywords,
& updating values of any entry. Also provide facility to display whole data sorted in ascending/ Descending
order, Also find how many maximum comparisons may require for finding any keyword. Make use of
appropriate data structures
//============================================================================*/


//Assignment No. 2  - Dictionary

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define size 50


   int creat();
   int insert(int n);
   int delet(int n);
   int display(int n);
   int modify(int n);
   int sort(int n);
   int search(int n);

struct dictionary
{
 char word[20];
 char meaning[30];
 char key[20];
}d[size];

int main()
{
   int ch,n=0;

do
{
 printf("\n 1.Insert \n 2.Delete \n 3.Update \n 4.Sort \n 5.Search \n 6.Display \n 7. Exit");
 printf("\n Enter your choice: ");
 scanf("%d",&ch);

 switch(ch)
{
  case 1:
       n=insert(n);
       display(n);
       break;
  case 2: delet(n);
       display(n);
       break;
  case 3:
       modify(n);
       display(n);
       break;
  case 4:
       sort(n);
       display(n);  
       break;
  case 5:
       search(n);
       break;
  case 6:
       display(n);
       break;
  case 7:
       exit(0);
       break;
   default: printf("\nWrong choice...!!!");
 }

    printf("\n\nDo You want to Continue(1.Yes/2.No): ");
     scanf("%d",&ch);
      
    }while(ch==1);
 
}




int creat()
{
int i,n;
for(i=0;i<n;i++)
{
    strcpy(d[i].word,"");
    strcpy(d[i].meaning,"");
    }
}


int insert (int i)
{
  int n,j;
  printf("\n\n How many Words you want to insert: ");
  scanf("%d",&j);
 
  for(i=0;i<j;i++)
   {
    printf("\nEnter the no. %d word: ",i+1);
    scanf("%s",d[i].word);
    printf(" Enter its Meaning: ");
    scanf("%s",d[i].meaning);
   }
    printf("\n\n %d words are inserted successfully.\n\n",j);
}


int delet(int n)
{
  int i, flag=0;
  printf("\n\n Enter the Word to be Deleted: ");
  scanf("%s",d[0].key);
    for( i=0;i<n;i++)
    {
     if((strcmp(d[i].word,d[0].key)==0))
     {
            strcpy(d[i].word,"");
          strcpy(d[i].meaning,"");
          flag=1;
     }
    }
        printf("\n\n Specified word is deleted successfully.\n\n");
    if(flag==0)
           printf("\n\n Specified word not found !!!\n\n");
   
}


int modify(int n)
{
 int i;
 int nr,nm;
 char *key;
 char nword[20];
 char nmeaning[20];

 printf("\n Enter the word to Update:");
 scanf("%s",key);
 for( i=0;i<n;i++)
  {
   if((strcmp(d[i].word,key)==0)) 
   {
     printf("\n Enter the New Word: ");
     scanf("%s",nword);
     printf("Enter the New meaning: ");
     scanf("%s",nmeaning);
     strcpy(d[i].word,nword);
     strcpy(d[i].meaning,nmeaning);
    }
   }
printf("\n\n Specified word is updated successfully.\n\n");
}


int display(int n)
{
 int i;
 printf("\n\n**** DICTIONARY ***\n");
 printf("\nSr.No.     WORD             MEANING  \n");
 printf(".......................................\n");
 for(i=0;i<n;i++)
 {
    if((strcmp(d[i].word,"")!=0))
     printf("\n   %d\t   %s\t     %s",i+1,d[i].word,d[i].meaning);
 }
  printf("\n.......................................\n");
}



int search(int n)
{
 int i,flag=0;

 printf("\n Enter the Word to be searched: ");
 scanf("%s",d[1].key);
 for(i=0;i<n;i++)
 {

    if((strcmp(d[i].word,d[1].key)==0))
    {
     flag=1;
     break;
    }
 }
 if(flag==1)
 {
printf("\nThe word with its meaning is Displayed below:\n");
  printf("\n  %s : %s \n\n",d[1].key,d[i].meaning);
 }
 else
  printf("\n The Word Is Not Present");
}


int sort(int n)
{
 int i,j,ch;
 char temp_word[20];
 char temp_meaning[30];
 printf("\n1.Ascending\n2.Descending");
 printf("\nSelect Choice: ");
 scanf("%d",&ch);

 if(ch==1)
 {
  for(i=0;i<n;i++)
  {
   for(j=0;j<n-1;j++)
  {
   if((strcmp(d[i].word,d[j].word)<0))
    {
    strcpy(temp_word,d[i].word);
    strcpy(temp_meaning,d[i].meaning);

    strcpy(d[i].word,d[j].word);
    strcpy(d[i].meaning,d[j].meaning);

    strcpy(d[j].word,temp_word);
    strcpy(d[j].meaning,temp_meaning);
     }
    }
  }
  printf("\nDictionary Sorted In Ascending Order.\n\n");
 }

  else
  {
  for(i=0;i<n;i++)
  {
   for(j=0;j<n-1;j++)
   {
   if((strcmp(d[i].word,d[j].word)>0))
    {
    strcpy(temp_word,d[i].word);
    strcpy(temp_meaning,d[i].meaning);

    strcpy(d[i].word,d[j].word);
    strcpy(d[i].meaning,d[j].meaning);

    strcpy(d[j].word,temp_word);
    strcpy(d[j].meaning,temp_meaning);
    }
   }
  }
   printf("\nDictionary Sorted In Descending Order.\n\n");
  }
}




//============================================================================
// Author: Aman Bohra
//        ( bohraaman.blogspot.in)
// ROLL NO     : 007
// CLASS       : SE(COMPUTER)
// BATCH       : S1
// ASSIGNMENT NO.: 03
/* TITLE   :A news paper delivery boy every day drops news paper in a society having many lanes & each lane have
many houses. Design a program to provide different paths that he could follow & also suggest the path which
will make him to finish his task with less effort. Solve the problem by suggesting appropriate data structures.
Design necessary class.
//============================================================================*/

//Assignment No. : 3 - Newspaper Delivery Boy

#include<stdio.h>
#include<stdlib.h>

#define size 20
#define TRUE 1
#define FALSE 0

int v[size];
int st[10];
int Paths[10][10];
int top,row;
int n=4;

int main()
{
    int v1,i,j,sum[10];
    int PathCompute(int v1, int g[size][size]);
    int g[size][size] = {{0,5,9999,2},
                {5,0,7,1},
                {9999,7,0,4},
                {2,1,4,0},
                };

    printf("\nProgram for finding various paths for a Newspaper Boy-\n");
    row=-1;

    for(i=0;i<size;i++)
        sum[i]=9999;
   
    for(v1=0;v1<n;v1++)
    {
        for(i=0;i<n;i++)
        {
            st[i]=0;
            }
    top=-1;
    printf("\n Path");
    if(v1>=n)
        printf("Invalid Lane.\n");
    else
    {
        PathCompute(v1,g);
        printf("\n");
        sum[v1]=0;
        for(i=0,j=1;i<n-1;i++,j++)
            sum[v1]=sum[v1]+g[Paths[v1][i]][Paths[v1][j]];
        printf("\t Total Distance Travelled : %d\n", sum[v1]);
        printf("\n-----------------------------");
        }
    }

    int mindist=sum[0];
    int mark=0;
    for(i=0;i<n;i++)
    {
        if(sum[i]<mindist)
        {
            mindist=sum[i];
            mark=i;
            }
        }
    printf("\n\n The Minimum Effort Path :");
    for(j=0;j<n;j++)
    {   
        printf("\t%d",Paths[mark][j]);
        }
printf("\n\n");
return 0;
}

int PathCompute(int v1,int g[size][size])
{
    int i,v2,col=0;
    row++;
    int push(int item);
    int efforts(int v,int row,int col);
    int pop();
   
    for(i=0;i<n;i++)
        v[i]=FALSE;
    push(v1);
        while(top!=-1)
        {
            v1=pop();
            if(v[v1]==FALSE)
            {
                printf("- Lane %d ",v1);
                v[v1]=TRUE;
                efforts(v1,row,col++);
                }
    for(v2=0;v2<n;v2++)
        if(g[v1][v2]!=0 && v[v2]==FALSE)
            push(v2);
        }
    }

int push(int item)
{
    st[++top]=item;
    }

int pop()
{
    int item;
    item=st[top];
    top--;
    return item;
    }

int efforts(int v, int r, int c)
{
    Paths[r][c]=v;
    }

//============================================================================
// Author: Aman Bohra
//        ( bohraaman.blogspot.in)
// ROLL NO     : 007
// CLASS       : SE(COMPUTER)
// BATCH       : S1
// ASSIGNMENT NO.: 04
/* TITLE   :Extending to problem 2. Consider dictionary data is stored in a file in random order. Thus, to search any
the word & its meanings from given data, program should create reasonably balanced tree.
//============================================================================*/
// Assignment No.- A4 - Dictionary using Tree (on window platform)

#include <stdio.h>
#include<iostream.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
#include<dos.h>
#define LEFT  1
#define RIGHT 2

struct node
{
 char word[20],meaning[100];
 node *left,*right;
};
node *maketree(char[],char[]);
node* treefromfile();
void filefromtree(node*);
void addword(node*,char[],char[]);
void seperateword(char[],char[],char[]);
void displayall(node*);
node* bsearch(node*,char[]);
void showmenu();
FILE *file_ptr;

void prog()
{
 clrscr();
 char word[20],meaning[100];
 int menuchoice;
 node *temp;
 temp=treefromfile();
 if(temp==NULL)
 {
  printf("
File does not exist or dictionary is empty...");
  getch();
 }
 while(1)
 {
  clrscr();
  showmenu();
  scanf("
%d",&menuchoice);
  switch(menuchoice)
  {
   case 1:printf("
Enter word : ");
      scanf("%s",word);
      printf("
Enter meaning : " );
      flushall();
      gets(meaning);
      if(temp==NULL)
       temp=maketree(word,meaning);
      else
       addword(temp,word,meaning);
      break;
   case 2:if(temp==NULL)
       printf("
The dictionary is empty...");
      else
      {
       printf("
Find meaning of : ");
       flushall();
       gets(word);
       node *t;
       t=bsearch(temp,word);
       if(t==NULL)
        printf("
Word not found...");
       else
       {
        printf("

%s : ",t->word);
        puts(t->meaning);
       }
      }
      getch();
      break;
   case 3:if(temp==NULL)
       printf("
Dictionary is empty...");
      else
       displayall(temp);
      getch();
      break;
   case 4:filefromtree(temp);
      exit(1);
      break;
   default:cout<<"

Enter Again";
       delay(1000);
       prog();
       break;
  }
 }
}
void showmenu()
{
 printf("
        COMPUTER DICTIONARY");
 printf("
[1].    Add a word.");
 printf("
[2].    Find meaning.");
 printf("
[3].    Display all.");
 printf("
[4]. Save and Close.

Enter Choice");
}
node* treefromfile()
{
 node *ptree=NULL;
 char word[20],meaning[100],str[120],*i;
 int flags=0;
 file_ptr=fopen("C:\dict.anu","r");
 if(file_ptr==NULL)
  ptree=NULL;
 else
 {
 while(!feof(file_ptr))
  {
    i=fgets(str,120,file_ptr);
    if(i==NULL)
    break;
    seperateword(str,word,meaning);
    if(flags==0)
    {
     ptree=maketree(word,meaning);
     flags=1;
    }
    else
     addword(ptree,word,meaning);
  }

 fclose(file_ptr);
 }
 return ptree;
}
node* maketree(char w[],char m[])
{
 node *p;
 p=new node;
 strcpy(p->word,w);
 strcpy(p->meaning,m);
 p->left=NULL;
 p->right=NULL;
 return p;
}
void seperateword(char str[],char w[],char m[])
{
 int i,j;
 for(i=0;str[i]!=' ';i++)
  w[i]=str[i];
 w[i++]=NULL;    //Append the null and skip the space.
 for(j=0;str[i]!='
';i++,j++)
 {
  m[j]=str[i];
 }
 m[j]=NULL;
}
void addword(node *tree,char word[],char meaning[])
{
 node *p,*q;
 p=q=tree;
 while(strcmp(word,p->word)!=0 && p!=NULL)
 {
  q=p;
  if(strcmp(word,p->word)<0)
   p=p->left;
  else
   p=p->right;
 }
 if(strcmp(word,q->word)==0)
 {
  printf("
This word already exists...");
  delay(1000);
 }
 else if(strcmp(word,q->word)<0)
  q->left=maketree(word,meaning);
 else
  q->right=maketree(word,meaning);
}
node* bsearch(node *tree,char word[])
{
 node *q;
 q=tree;
 while(q!=NULL)
 {
  //p=q;
  if(strcmp(word,q->word)<0)
   q=q->left;
  else if(strcmp(word,q->word)>0)
   q=q->right;
  if(strcmp(word,q->word)==0)
   break;
 }
 return q;
}
void filefromtree(node *tree)
{
 void travandwrite(node*);
 file_ptr=fopen("C:\dict.anu","w");
 if(file_ptr==NULL)
 {
  printf("
Cannot open file for writing data...");
 }
 else //if(tree==NULL)
 {
  if(tree!=NULL)
  {
   travandwrite(tree);
  }
  fclose(file_ptr);  //Close the file anyway.
 }
}
void travandwrite(node *tree)
{
 if(tree!=NULL)
 {
  fprintf(file_ptr,"%s %s
",tree->word,tree->meaning);
  travandwrite(tree->left);
  travandwrite(tree->right);
 }
}
void displayall(node *tree)
{
 if(tree!=NULL)
 {
  displayall(tree->left);
  printf("%s : %s
",tree->word,tree->meaning);
  displayall(tree->right);
 }
}
void intro()
{
int i;
clrscr();
gotoxy(20,20);
cout<<"DICTIONARY LOADING";
for(i=0;i<50;i++)
{
 gotoxy(15+i,21);
 cout<<"รพรพรพ";
 gotoxy(20,22);
 cout<<2*i<<"% completed";
 delay(150);
}
gotoxy(20,20);
cout<<"DICTIONARY LOADING COMPLETED";
clrscr();
}
void main()
{
clrscr();
intro();
prog();
}


Group-B


//============================================================================
// Author: Aman Bohra
//        ( bohraaman.blogspot.in)
// ROLL NO     : 007
// CLASS       : SE(COMPUTER)
// BATCH       : S1
// ASSIGNMENT NO.: 1
/* TITLE   :Write a program using object oriented programming features to implement Doubly circular linked list with
different manipulation facilities in C++
//============================================================================*/
    /*Assignment No:=B1*

     * C++ Program to Implement Circular Doubly Linked List*/

    #include<iostream>

    #include<cstdio>

    #include<cstdlib>

    using namespace std;

      struct node

    {
    int info;

        struct node *next;

        struct node *prev;

    }*start, *last;

    int counter = 0;

    class double_clist

    { public:

            node *create_node(int);

            void insert_begin();

            void insert_last();

            void insert_pos();

            void delete_pos();

            void search();

            void update();

            void display();

            void reverse();

            void sort();

            double_clist()

            {

                start = NULL;

                last = NULL;           

            } };
 int main()

    {

        int choice;

        double_clist cdl;

        while (1)

        {
            cout<<"\n-------------------------------"<<endl;

            cout<<"Operations on Doubly Circular linked list"<<endl;

            cout<<"\n-------------------------------"<<endl;         

            cout<<"1.Insert at Beginning"<<endl;

            cout<<"2.Insert at Last"<<endl;

            cout<<"3.Insert at Position"<<endl;

            cout<<"4.Delete at Position"<<endl;

            cout<<"5.Update Node"<<endl;

            cout<<"6.Search Element"<<endl;

            cout<<"7.Sort"<<endl;

            cout<<"8.Display List"<<endl;

            cout<<"9.Reverse List"<<endl;

            cout<<"10.Exit"<<endl;

            cout<<"Enter your choice : ";

            cin>>choice;

            switch(choice)

            {

            case 1:

                cdl.insert_begin();

                break;
 case 2:

                cdl.insert_last();

                break;   

            case 3:

                cdl.insert_pos();

                break; 

            case 4:

                cdl.delete_pos();

                break;

            case 5:

                cdl.update();

                break;

            case 6:

                cdl.search();

                break;

            case 7:

                cdl.sort();

                break;

            case 8:

                cdl.display();

                break;

            case 9:

                cdl.reverse();

                break;

            case 10:

                exit(1); 

            default:

                cout<<"Wrong choice"<<endl;   
 } }

        return 0;
    }

       node* double_clist::create_node(int value)

    {

        counter++;  

        struct node *temp;

        temp = new(struct node);

        temp->info = value;

        temp->next = NULL;

        temp->prev = NULL;

        return temp;

    }
 void double_clist::insert_begin()
{
        int value;

        cout<<endl<<"Enter the element to be inserted: ";

        cin>>value;

        struct node *temp;

        temp = create_node(value);

        if (start == last && start == NULL)
{    cout<<"Element inserted in empty list"<<endl;

            start = last = temp;

            start->next = last->next = NULL;

            start->prev = last->prev = NULL;

        }

        else

        {

            temp->next = start;

            start->prev = temp;

            start = temp;

            start->prev = last;

            last->next = start;

            cout<<"Element inserted"<<endl;

        } }
    void double_clist::insert_last()

    {

        int value;    

        cout<<endl<<"Enter the element to be inserted: ";

        cin>>value; 

        struct node *temp;

        temp = create_node(value);

        if (start == last && start == NULL)

        {

            cout<<"Element inserted in empty list"<<endl;

            start = last = temp;

            start->next = last->next = NULL;    

            start->prev = last->prev = NULL;

        }
else
{
            last->next = temp;

            temp->prev = last;

            last = temp;

            start->prev = last;

            last->next = start;

        }

    }
    void double_clist::insert_pos()

    {    

        int value, pos, i;

        cout<<endl<<"Enter the element to be inserted: ";

        cin>>value;

        cout<<endl<<"Enter the postion of element inserted: ";

        cin>>pos;

        struct node *temp, *s, *ptr;

        temp = create_node(value);

        if (start == last && start == NULL)

        {

            if (pos == 1)

            {

                start = last = temp;

                start->next = last->next = NULL;    

                start->prev = last->prev = NULL;

            }

            else

            {

                cout<<"Position out of range"<<endl;

                counter--;

                return;

            }

        }  

        else

        {

            if (counter < pos)

            {

                 cout<<"Position out of range"<<endl;

                 counter--;

                 return;          

            }

            s = start;       

            for (i = 1;i <= counter;i++)

            {

                ptr = s;

                s = s->next;

                if (i == pos - 1)

                {

                    ptr->next = temp;

                    temp->prev = ptr;

                    temp->next = s;

                    s->prev = temp;

                    cout<<"Element inserted"<<endl;

                   } } } }

    void double_clist::delete_pos()

    {    

        int pos, i;

        node *ptr, *s;

        if (start == last && start == NULL)

        {

            cout<<"List is empty, nothing to delete"<<endl;

            return;

        }

        cout<<endl<<"Enter the postion of element to be deleted: ";

        cin>>pos;

        if (counter < pos)

        {

            cout<<"Position out of range"<<endl;

            return;

        }

        s = start;

        if(pos == 1)

        {

            counter--;

            last->next = s->next;

            s->next->prev = last;

            start = s->next;

            free(s);

            cout<<"Element Deleted"<<endl;

            return;       

        }

        for (i = 0;i < pos - 1;i++ )

        {  

            s = s->next;

            ptr = s->prev;          

        }    

        ptr->next = s->next;

        s->next->prev = ptr;

        if (pos == counter)

        {

            last = ptr;        

        }

        counter--;

        free(s);

        cout<<"Element Deleted"<<endl;

    }

    void double_clist::update()

    {

        int value, i, pos;

        if (start == last && start == NULL)

        {

            cout<<"The List is empty, nothing to update"<<endl;

            return; 

        }

        cout<<endl<<"Enter the postion of node to be updated: ";

        cin>>pos;

        cout<<"Enter the new value: ";

        cin>>value;

        struct node *s;

        if (counter < pos)

        {

            cout<<"Position out of range"<<endl;

            return;

        }

        s = start;  

        if (pos == 1)

        {

           s->info = value;

           cout<<"Node Updated"<<endl;

           return;   

        }

        for (i=0;i < pos - 1;i++)

        {

            s = s->next;          

        }

        s->info = value;

        cout<<"Node Updated"<<endl;

    }

    void double_clist::search()

    {

        int pos = 0, value, i;

        bool flag = false;

        struct node *s;

        if (start == last && start == NULL)

        {

            cout<<"The List is empty, nothing to search"<<endl;

            return;

        }

        cout<<endl<<"Enter the value to be searched: ";

        cin>>value;

        s = start;

        for (i = 0;i < counter;i++)

        {

            pos++;

            if (s->info == value)

            {

                cout<<"Element "<<value<<" found at position: "<<pos<<endl;

                flag = true;

            }    

            s = s->next;

        }

        if (!flag)

            cout<<"Element not found in the list"<<endl;   

    }

    

    void double_clist::sort()

    {

        struct node *temp, *s;

        int value, i;

        if (start == last && start == NULL)

        {

            cout<<"The List is empty, nothing to sort"<<endl;

            return;

        }

        s = start;

        for (i = 0;i < counter;i++)

        {

            temp = s->next;

            while (temp != start)

            {

                if (s->info > temp->info)

                {

                    value = s->info;

                    s->info = temp->info;

                    temp->info = value;

                }

                temp = temp->next;

            }

            s = s->next;

        }  }

    void double_clist::display()

    {

        int i;

        struct node *s;

        if (start == last && start == NULL)

        {

            cout<<"The List is empty, nothing to display"<<endl;

            return;

        }

        s = start;

        for (i = 0;i < counter-1;i++)

        {   

            cout<<s->info<<"<->";

            s = s->next; 

        }

        cout<<s->info<<endl;

    }

    void double_clist::reverse()

    {

        if (start == last && start == NULL)

        {

            cout<<"The List is empty, nothing to reverse"<<endl;

            return;

        }

        struct node *p1, *p2;

        p1 = start;

        p2 = p1->next;

        p1->next = NULL;

        p1->prev = p2;

        while (p2 != start)

        {

            p2->prev = p2->next;

            p2->next = p1;

            p1 = p2;

            p2 = p2->prev; }

        last = start;

        start = p1;

        cout<<"List Reversed"<<endl;      

    }

/* OUTPUT 
$ g++ doublycircular_llist.cpp
$ a.out
---------------------------------
 
Operations on Doubly Circular linked list
 
---------------------------------
1.Insert at Beginning
2.Insert at Last
3.Insert at Position
4.Delete at Position
5.Update Node
6.Search Element
7.Sort
8.Display List
9.Reverse List
10.Exit
Enter your choice : 4
List is empty, nothing to delete
 
---------------------------------
 
Operations on Doubly Circular linked list
 
---------------------------------
1.Insert at Beginning
2.Insert at Last
3.Insert at Position
4.Delete at Position
5.Update Node
6.Search Element
7.Sort
8.Display List
9.Reverse List
10.Exit
Enter your choice : 5
The List is empty, nothing to update
 
---------------------------------
 
Operations on Doubly Circular linked list
 
---------------------------------
1.Insert at Beginning
2.Insert at Last
3.Insert at Position
4.Delete at Position
5.Update Node
6.Search Element
7.Sort
8.Display List
9.Reverse List
10.Exit
Enter your choice : 6
The List is empty, nothing to search
 
---------------------------------
 
Operations on Doubly Circular linked list
 
---------------------------------
1.Insert at Beginning
2.Insert at Last
3.Insert at Position
4.Delete at Position
5.Update Node
6.Search Element
7.Sort
8.Display List
9.Reverse List
10.Exit
Enter your choice : 7
The List is empty, nothing to sort
 
---------------------------------
 
Operations on Doubly Circular linked list
 
---------------------------------
1.Insert at Beginning
2.Insert at Last
3.Insert at Position
4.Delete at Position
5.Update Node
6.Search Element
7.Sort
8.Display List
9.Reverse List
10.Exit
Enter your choice : 8
The List is empty, nothing to display
 
---------------------------------
 
Operations on Doubly Circular linked list
 
---------------------------------
1.Insert at Beginning
2.Insert at Last
3.Insert at Position
4.Delete at Position
5.Update Node
6.Search Element
7.Sort
8.Display List
9.Reverse List
10.Exit
Enter your choice : 9
The List is empty, nothing to reverse
 
---------------------------------
 
Operations on Doubly Circular linked list
 
---------------------------------
1.Insert at Beginning
2.Insert at Last
3.Insert at Position
4.Delete at Position
5.Update Node
6.Search Element
7.Sort
8.Display List
9.Reverse List
10.Exit
Enter your choice : 1
 
Enter the element to be inserted: 100
Element inserted in empty list
 
---------------------------------
 
Operations on Doubly Circular linked list
 
---------------------------------
1.Insert at Beginning
2.Insert at Last
3.Insert at Position
4.Delete at Position
5.Update Node
6.Search Element
7.Sort
8.Display List
9.Reverse List
10.Exit
Enter your choice : 2
 
Enter the element to be inserted: 200
 
---------------------------------
 
Operations on Doubly Circular linked list
 
---------------------------------
1.Insert at Beginning
2.Insert at Last
3.Insert at Position
4.Delete at Position
5.Update Node
6.Search Element
7.Sort
8.Display List
9.Reverse List
10.Exit
Enter your choice : 8
100<->200
 
---------------------------------
 
Operations on Doubly Circular linked list
 
---------------------------------
1.Insert at Beginning
2.Insert at Last
3.Insert at Position
4.Delete at Position
5.Update Node
6.Search Element
7.Sort
8.Display List
9.Reverse List
10.Exit
Enter your choice : 3
 
Enter the element to be inserted: 150
 
Enter the postion of element inserted: 2
Element inserted
 
---------------------------------
 
Operations on Doubly Circular linked list
 
---------------------------------
1.Insert at Beginning
2.Insert at Last
3.Insert at Position
4.Delete at Position
5.Update Node
6.Search Element
7.Sort
8.Display List
9.Reverse List
10.Exit
Enter your choice : 8
100<->150<->200
 
---------------------------------
 
Operations on Doubly Circular linked list
 
---------------------------------
1.Insert at Beginning
2.Insert at Last
3.Insert at Position
4.Delete at Position
5.Update Node
6.Search Element
7.Sort
8.Display List
9.Reverse List
10.Exit
Enter your choice : 3
 
Enter the element to be inserted: 1010
 
Enter the postion of element inserted: 3
Element inserted
 
---------------------------------
 
Operations on Doubly Circular linked list
 
---------------------------------
1.Insert at Beginning
2.Insert at Last
3.Insert at Position
4.Delete at Position
5.Update Node
6.Search Element
7.Sort
8.Display List
9.Reverse List
10.Exit
Enter your choice : 8
100<->150<->1010<->200
 
---------------------------------
 
Operations on Doubly Circular linked list
 
---------------------------------
1.Insert at Beginning
2.Insert at Last
3.Insert at Position
4.Delete at Position
5.Update Node
6.Search Element
7.Sort
8.Display List
9.Reverse List
10.Exit
Enter your choice : 3
 
Enter the element to be inserted: 1111
 
Enter the postion of element inserted: 50
Position out of range
 
---------------------------------
 
Operations on Doubly Circular linked list
 
---------------------------------
1.Insert at Beginning
2.Insert at Last
3.Insert at Position
4.Delete at Position
5.Update Node
6.Search Element
7.Sort
8.Display List
9.Reverse List
10.Exit
Enter your choice : 4
 
Enter the postion of element to be deleted: 3
Element Deleted
 
---------------------------------
 
Operations on Doubly Circular linked list
 
---------------------------------
1.Insert at Beginning
2.Insert at Last
3.Insert at Position
4.Delete at Position
5.Update Node
6.Search Element
7.Sort
8.Display List
9.Reverse List
10.Exit
Enter your choice : 8
100<->150<->200
 
---------------------------------
 
Operations on Doubly Circular linked list
 
---------------------------------
1.Insert at Beginning
2.Insert at Last
3.Insert at Position
4.Delete at Position
5.Update Node
6.Search Element
7.Sort
8.Display List
9.Reverse List
10.Exit
Enter your choice : 5
 
Enter the postion of node to be updated: 2
Enter the new value: 1111
Node Updated
 
---------------------------------
 
Operations on Doubly Circular linked list
 
---------------------------------
1.Insert at Beginning
2.Insert at Last
3.Insert at Position
4.Delete at Position
5.Update Node
6.Search Element
7.Sort
8.Display List
9.Reverse List
10.Exit
Enter your choice : 8
100<->1111<->200
 
---------------------------------
 
Operations on Doubly Circular linked list
 
---------------------------------
1.Insert at Beginning
2.Insert at Last
3.Insert at Position
4.Delete at Position
5.Update Node
6.Search Element
7.Sort
8.Display List
9.Reverse List
10.Exit
Enter your choice : 6
 
Enter the value to be searched: 200
Element 200 found at position: 3
 
---------------------------------
 
Operations on Doubly Circular linked list
 
---------------------------------
1.Insert at Beginning
2.Insert at Last
3.Insert at Position
4.Delete at Position
5.Update Node
6.Search Element
7.Sort
8.Display List
9.Reverse List
10.Exit
Enter your choice : 5
 
Enter the postion of node to be updated: 14
Enter the new value: 45
Position out of range
 
---------------------------------
 
Operations on Doubly Circular linked list
 
---------------------------------
1.Insert at Beginning
2.Insert at Last
3.Insert at Position
4.Delete at Position
5.Update Node
6.Search Element
7.Sort
8.Display List
9.Reverse List
10.Exit
Enter your choice : 8
100<->1111<->200
 
---------------------------------
 
Operations on Doubly Circular linked list
 
---------------------------------
1.Insert at Beginning
2.Insert at Last
3.Insert at Position
4.Delete at Position
5.Update Node
6.Search Element
7.Sort
8.Display List
9.Reverse List
10.Exit
Enter your choice : 7
 
---------------------------------
 
Operations on Doubly Circular linked list
 
---------------------------------
1.Insert at Beginning
2.Insert at Last
3.Insert at Position
4.Delete at Position
5.Update Node
6.Search Element
7.Sort
8.Display List
9.Reverse List
10.Exit
Enter your choice : 8
100<->200<->1111
 
---------------------------------
 
Operations on Doubly Circular linked list
 
---------------------------------
1.Insert at Beginning
2.Insert at Last
3.Insert at Position
4.Delete at Position
5.Update Node
6.Search Element
7.Sort
8.Display List
9.Reverse List
10.Exit
Enter your choice : 9
List Reversed
 
---------------------------------
 
Operations on Doubly Circular linked list
 
---------------------------------
1.Insert at Beginning
2.Insert at Last
3.Insert at Position
4.Delete at Position
5.Update Node
6.Search Element
7.Sort
8.Display List
9.Reverse List
10.Exit
Enter your choice : 8
1111<->200<->100
 
---------------------------------
 Operations on Doubly Circular linked list
 ---------------------------------
1.Insert at Beginning
2.Insert at Last
3.Insert at Position
4.Delete at Position
5.Update Node
6.Search Element
7.Sort
8.Display List
9.Reverse List
10.Exit
Enter your choice : 10

//============================================================================
// Author: Aman Bohra
//        ( bohraaman.blogspot.in)
// ROLL NO     : 007
// CLASS       : SE(COMPUTER)
// BATCH       : S1
// ASSIGNMENT NO.: 2
/* TITLE   :Write a modular program using object oriented programming features to implement different sorting
methods(quick, merge, radix, shell, heap sort) using Python
//============================================================================*/

//All Python Program

*Assignment NO:=B2 heap*
def heapsort( aList ):
  # convert aList to heap
  length = len( aList ) - 1
  leastParent = length / 2
  for i in range ( leastParent, -1, -1 ):
    moveDown( aList, i, length )
 
  # flatten heap into sorted array
  for i in range ( length, 0, -1 ):
    if aList[0] > aList[i]:
      swap( aList, 0, i )
      moveDown( aList, 0, i - 1 )
 
 
def moveDown( aList, first, last ):
  largest = 2 * first + 1
  while largest <= last:
    # right child exists and is larger than left child
    if ( largest < last ) and ( aList[largest] < aList[largest + 1] ):
      largest += 1
 
    # right child is larger than parent
    if aList[largest] > aList[first]:
      swap( aList, largest, first )
      # move down to largest child
      first = largest;
      largest = 2 * first + 1
    else:
      return # force exit
 
 
def swap( A, x, y ):
  tmp = A[x]
  A[x] = A[y]
  A[y] = tmp

*Assignment No:=B2 merge*


list=[]
  list1=[]
  list2=[]
  def merge(list,list1,list2):

  for k in range(1,len(list1)+len(list2)):
    i=1
    j=1
    if list1[i]>list2[j]:
        list[k]=list2[j]
        j=+1
        k=+1
    else:
        list[k]=list2[i]
        i=+1
        k=+1


    def split(list,list1,list2):
if len(list)<>1:
    list1=list[:len(list)/2]
    list2=list[len(list)/2:]
return  


   def sort(list):
      split(list,list1,list2)
      sort(list1)
      sort(list2)
      merge(list,list1,list2)


      list = [15,8,59,69,45,23]
      sort(list)

*Assignment No:=B2 Quick*

def sort(array=[12,4,5,6,7,3,1,15]):
    less = []
    equal = []
    greater = []

    if len(array) > 1:
        pivot = array[0]
        for x in array:
            if x < pivot:
                less.append(x)
            if x == pivot:
                equal.append(x)
            if x > pivot:
                greater.append(x)
            sort(less)
            sort(pivot)
            sort(greater)

*Assignment No:=B2 Radix*

def radixsort( aList ):
  RADIX = 10
  maxLength = False
  tmp , placement = -1, 1
 
  while not maxLength:
    maxLength = True
    # declare and initialize buckets
    buckets = [list() for _ in range( RADIX )]
 
    # split aList between lists
    for  i in aList:
      tmp = i / placement
      buckets[tmp % RADIX].append( i )
      if maxLength and tmp > 0:
        maxLength = False
 
    # empty lists into aList array
    a = 0
    for b in range( RADIX ):
      buck = buckets[b]
      for i in buck:
        aList[a] = i
        a += 1
 
    # move to next digit
    placement *= RADIX

*Assignment NO:=B2 shell*

def shellSort(items):
    inc = len(items) / 2
    while inc:
        for i in xrange(len(items)):
            j = i
            temp = items[i]
            while j >= inc and items[j-inc] > temp:
                items[j] = items[j - inc]
                j -= inc
            items[j] = temp
        inc = inc/2 if inc/2 else (0 if inc==1 else 1)

a = [35, -8, 11, 1, 68, 0, 3];
shellSort(a)
print a
//============================================================================
// Author: Aman Bohra
//        ( bohraaman.blogspot.in)
// ROLL NO     : 007
// CLASS       : SE(COMPUTER)
// BATCH       : S1
// ASSIGNMENT NO.: 4
/* TITLE   :Write a program using object oriented programming using C++ to create a binary tree if inorder& preorder or
inorder & postorder any two traversals are given.
//============================================================================*/
// Assignment No. B4 : Binary Tree Traversals

#include<iostream>
using namespace std;

typedef struct Node
      {
     int data;
     struct Node *left;
     struct Node *right;
      }node;

class BIN_TREE
{
      public:
      node *root,*New;
      BIN_TREE();
      void create();
      void insert(node*,node*);
      void inorder(node*);
      void preorder(node*);
      void postorder(node*);
};

class Stack
{
    public:
    node *data[20];
    int Top;
    int isempty();
    void push(node *);
    node *pop();

    Stack()
    {
       Top=-1;
    }
};

int Stack::isempty()
{
    if(Top==-1)
        return 1;
    else
        return(0);
}

void Stack::push(node *p)
{
    Top++;
    data[Top]=p;
}

node *Stack::pop()
{

    return(data[Top--]);
}

BIN_TREE::BIN_TREE()
{
    root=NULL;
}

void BIN_TREE::create()
{
    char ch,ans;
    do
    {
        New=new node;
        cout<<" \n Enter the Value for the Node (Should be Numeric only):";
        cin>>New->data;
        New->left=New->right=NULL;

        if(root==NULL)
            root=New;
        else
            insert(root,New);
            cout<<"\n Do you want to more nodes (y/n)?";
            cin>>ch;
            ans=ch;

    }while(ans=='y'||ans=='Y');
}


void BIN_TREE::insert(node* root,node* New)
{
    char ch;
    cout<<"\n Where you want to attach this node ?";
    cout<<"\n Insert to left or right of "<<root->data<<" (l/r)?";
    cin>>ch;
    {
        if(ch=='l'||ch=='L')
        {
            if(root->left==NULL)
                root->left=New;
            else
                insert(root->left,New);
        }
        else
        {
            if(root->right==NULL)
                root->right=New;
            else
                insert(root->right,New);
        }
    }
}

void BIN_TREE::preorder(node *R)
{
    if(R!=NULL)
    {   
        cout<<R->data<<"\t";
        preorder(R->left);
        preorder(R->right);
    }
}

void BIN_TREE::inorder(node *R)
{
    if(R!=NULL)
    {
        inorder(R->left);
        cout<<R->data<<"\t";
        inorder(R->right);
    }
}

void BIN_TREE::postorder(node *R)
{
    if(R!=NULL)
    {
        inorder(R->left);
        inorder(R->right);
        cout<<R->data<<"\t";
    }
}

int main()
{   
    int choice;
    BIN_TREE obj;
    do
    {
        cout<<"\n\n\n You have following Choices:";
        cout<<"\n 1:Create a Tree \n 2:Find Preorder \n 3:Find Inorder";
        cout<<"\n 4:Find Postorder \n 5:Exit";
        cout<<"\n\n Enter your Choice:";
        cin>>choice;

        switch(choice)
        {
            case 1:
                obj.create();
                break;
            case 2:
                if(obj.root==NULL)
                    cout<<"\n There is no tree \n";
                else
                    cout<<"\n\nThe Preorder for the given Tree is :  ";
                    obj.preorder(obj.root);
                    break;

            case 3:
                if(obj.root==NULL)
                    cout<<"\n There is no tree \n";   
                else
                    cout<<"\nThe Inorder for the given Tree is :  ";
                    obj.inorder(obj.root);
                    break;
            case 4:
                if(obj.root==NULL)
                    cout<<"\n There is no tree \n";
                else
                    cout<<"\nThe Postorder for the given Tree is :  ";
                    obj.postorder(obj.root);
                    break;

            case 5:
                    //exit(0);
                    break;

        }

    }while(choice!=5);
    return (0);
}
//============================================================================
// Author: Aman Bohra
//        ( bohraaman.blogspot.in)
// ROLL NO     : 007
// CLASS       : SE(COMPUTER)
// BATCH       : S1
// ASSIGNMENT NO.: 5
/* TITLE   :Write a C++ program to implement traversals on Threaded Binary Tree using object oriented programming
features. Design necessary class.
//============================================================================*/
// Assignment No.: B5 - Threaded Binary Tree


#include<iostream>

using namespace std;

 typedef struct Node
      {
     int data;
     struct Node *left;
     struct Node *right;
     int lbit,rbit;//0 thread 1 normal pointer
     int isleft;//1 leftchild 0 rt child

      }node;

class Thread_BIN_TREE
{
      public:
      node *root,*New;
      Thread_BIN_TREE();
      void create();
      void insert(node*,node*);
      node * inorder_succ(node*);
      node * preorder_succ(node*);
      node * postorder_succ(node*);
      node * father(node*);
      void nonrec_inorder();
      void nonrec_preorder();
      void nonrec_postorder();
};




Thread_BIN_TREE::Thread_BIN_TREE()
{   
    root=new Node;
    root->lbit=0;
    root->rbit=1;
    root->left=root->right=root;
}


void Thread_BIN_TREE::create()
{
    char ch,ans;
    do
    {
        New=new node;
        cout<<" \n Enter node data:";
        cin>>New->data;
        New->left=New->right=NULL;
            if(root->lbit==0)
            {
              New->isleft=1;
           
              New->left=root->left;
              New->lbit=root->lbit;   
              New->right=root;
              New->rbit=0;

              root->left=New;   
              root->lbit=1;
            }
            else   
            {
           
             insert(root->left,New);
            }
            cout<<"\n Do you want to more nodes(y/n)?";
            cin>>ch;
            ans=ch;

    }while(ans=='y'||ans=='Y');
}


void Thread_BIN_TREE::insert(node* root,node* New)
{
    char ch;
    cout<<"\n Insert to left or right"<<root->data<<"(l/r)?";
    cin>>ch;
    {
        if(ch=='l'||ch=='L')
        {
            New->isleft=1;
            if(root->lbit==0)
            {
              New->left=root->left;
              New->lbit=root->lbit;   
              New->right=root;
              New->rbit=0;

              root->left=New;   
              root->lbit=1;
   

            }
            else
                {
                             
                  insert(root->left,New);   
                }       
        }
        else
        {
            New->isleft=0;
            if(root->rbit==0)
                {
                  New->left=root;
                  New->lbit=0;   
                  New->right=root->right;
                  New->rbit=0;

                  root->right=New;   
                  root->rbit=1;   
                }
            else
                insert(root->right,New);
        }
    }
}


void Thread_BIN_TREE::nonrec_preorder()
{
        node *T;
    T=root->left;

    while(T!=root)
    {
        cout<<"\t"<<T->data;
        T=preorder_succ(T);
    }
}
       
 node * Thread_BIN_TREE::preorder_succ(node* T)
{
if(T->lbit==1)
 return(T->left);
if(T->rbit==1)
 return(T->right);
while(T->rbit==0)
T=T->right;
 return(T->right);

}

void Thread_BIN_TREE::nonrec_postorder()
{
   
    node *T;
    T=root->left;
    while(T->lbit==1 || T->rbit==1)
    {
        if(T->lbit==1)
        T=T->left;
        else
        T=T->right;
    }

    while(T!=root)
    {
        cout<<"\t"<<T->data;
        T=postorder_succ(T);
    }
}


 node * Thread_BIN_TREE::father(node* T)
 {
    if(T->isleft==1)//isleft 1 for leftchild
    {
    while(T->rbit==1)
    T=T->right;
     return(T->right);
    }
    else
    {
    while(T->lbit==1)
    T=T->left;
     return(T->left);

    }

 }

node * Thread_BIN_TREE::postorder_succ(node* T)
{

    if(T->isleft==1)
    {
         T=father(T);

        if(T->rbit==0)//fathers right is thread
        {
        return(T);
        }
        else
        {
             if(T=T->right)//if father is root
            return(T);
             T=T->right;
             while(T->lbit==1 || T->rbit==1)
             {
                if(T->lbit==1)
                T=T->left;
                else
                T=T->right;
                 return(T);
             }
       
        }

    }
    else
    {
     return(father(T));
    }

}


void Thread_BIN_TREE::nonrec_inorder()
{
   
    node *T;
    T=root->left;

    while(T->lbit==1)
    {
        T=T->left;
    }

    while(T!=root)
    {
    cout<<"\t"<<T->data;
    T=inorder_succ(T);
    }
}

node * Thread_BIN_TREE::inorder_succ(node* T)
{

if(T->rbit==1)
{
     T=T->right;

    while(T->lbit==1)
    {
        T=T->left;
    }
    return(T);
}


if(T->rbit==0)
{
    return(T->right);
}

}


int main()
{

   
    int choice;
    Thread_BIN_TREE obj;
    do
    {
        cout<<"\n You have following choices:";
        cout<<"\n 1:Create tree \n 2:Preorder Tree\n 3:Inorder Tree";
        cout<<"\n 4:Postorder Tree\n5:Exit";
        cout<<"\n Enter your choice:";
        cin>>choice;

        switch(choice)
        {
            case 1:
                obj.create();
                break;
           
            case 2:
                if(obj.root==NULL)
                    cout<<"\n There is no tree";
                else
                    obj.nonrec_preorder();
                    break;

            case 3:
                if(obj.root==NULL)
                    cout<<"\n There is no tree";
                else
                    obj.nonrec_inorder();
                    break;
            case 4:
                if(obj.root==NULL)
                    cout<<"\n There is no tree";
                else
                    obj.nonrec_postorder();
                    break;
            case 5:
                    //exit(0);
                    break;

        }

    }while(choice!=5);
    return (0);
}
//============================================================================
// Author: Aman Bohra
//        ( bohraaman.blogspot.in)
// ROLL NO     : 007
// CLASS       : SE(COMPUTER)
// BATCH       : S1
// ASSIGNMENT NO.: 7
/* TITLE   :Write a program to find shortest path for given source & destination of a given graph using C.
//============================================================================*/
// Assignment No.: B7 - Dijkstra's Shortest Path Algorithm.

#include<iostream>

#define INFINITY 999
 
using namespace std;
 
class Dijkstra{
    private:
        int adjMatrix[15][15];
        int predecessor[15],distance[15];
    int mark[15]; //keep track of visited node
        int source;
        int numOfVertices;
    public:

    /*
     Function read() reads No of vertices, Adjacency Matrix and source
     Matrix from the user. The number of vertices must be greather than
     zero, all members of Adjacency Matrix must be postive as distances
     are always positive. The source vertex must also be positive from 0
     to noOfVertices - 1
    */

        void read();
 
    /*
     Function initialize initializes all the data members at the begining of
     the execution. The distance between source to source is zero and all other
     distances between source and vertices are infinity. The mark is initialized
     to false and predecessor is initialized to -1
    */
 
        void initialize();
 
    /*
     Function getClosestUnmarkedNode returns the node which is nearest from the
     Predecessor marked node. If the node is already marked as visited, then it search
     for another node.
    */
 
        int getClosestUnmarkedNode();
    /*
     Function calculateDistance calculates the minimum distances from the source node to
     Other node.
    */
 
        void calculateDistance();
    /*
     Function output prints the results
    */
 
        void output();
        void printPath(int);
};
 
 
void Dijkstra::read(){
    cout<<"Enter the number of vertices of the graph(should be > 0)\n";
    cin>>numOfVertices;
    
    while(numOfVertices <= 0) {
            cout<<"Enter the number of vertices of the graph(should be > 0)\n";
            cin>>numOfVertices;
            }
    
    cout<<"Enter the adjacency matrix for the graph\n";
        cout<<"To enter infinity enter "<<INFINITY<<endl;
           
    for(int i=0;i<numOfVertices;i++) 
        {
                cout<<"Enter the (+ve)weights for the row "<<i<<endl;
        for(int j=0;j<numOfVertices;j++) 
        {
                    cin>>adjMatrix[i][j];
            
    while(adjMatrix[i][j]<0) 
        {
                cout<<"Weights should be +ve. Enter the weight again\n";
                cin>>adjMatrix[i][j];
            }
        }
    }
    cout<<"Enter the source vertex\n";
    cin>>source;
    while((source<0) && (source>numOfVertices-1)) 
    {
        cout<<"Source vertex should be between 0 and"<<numOfVertices-1<<endl;
        cout<<"Enter the source vertex again\n";
        cin>>source;
    }
}
 
 
void Dijkstra::initialize(){
    for(int i=0;i<numOfVertices;i++) {
    mark[i] = 0;
        predecessor[i] = -1;
        distance[i] = INFINITY;
    }
    distance[source]= 0;
}
 
 
int Dijkstra::getClosestUnmarkedNode(){
    int minDistance = INFINITY;
    int closestUnmarkedNode;
    for(int i=0;i<numOfVertices;i++) {
        if((!mark[i]) && ( minDistance >= distance[i])) {
            minDistance = distance[i];
            closestUnmarkedNode = i;
        }
    }
    return closestUnmarkedNode;
}
 
 
void Dijkstra::calculateDistance(){
    initialize();
    int minDistance = INFINITY;
    int closestUnmarkedNode;
    int count = 0;
    while(count < numOfVertices) {
        closestUnmarkedNode = getClosestUnmarkedNode();
    mark[closestUnmarkedNode] = 1;
        for(int i=0;i<numOfVertices;i++) {
            if((!mark[i]) && (adjMatrix[closestUnmarkedNode][i]>0) ) {
                if(distance[i] > distance[closestUnmarkedNode]+adjMatrix[closestUnmarkedNode][i]) {
                    distance[i] = distance[closestUnmarkedNode]+adjMatrix[closestUnmarkedNode][i];
                    predecessor[i] = closestUnmarkedNode;
                }
            }
        }
        count++;
    }
}
 
 
void Dijkstra::printPath(int node){
    if(node == source)
        cout<<(char)(node + 97)<<"..";
    else if(predecessor[node] == -1)
        cout<<"No path from “<<source<<”to "<<(char)(node + 97)<<endl;
    else {
        printPath(predecessor[node]);
        cout<<(char) (node + 97)<<"..";
    }
}
 
 
void Dijkstra::output(){
    for(int i=0;i<numOfVertices;i++) {
        if(i == source)
            cout<<(char)(source + 97)<<".."<<source;
        else
            printPath(i);
        cout<<"->"<<distance[i]<<endl;
    }
}
 
 
int main(){
    Dijkstra G;
    G.read();
    G.calculateDistance();
    G.output();
    return 0;
}
//============================================================================
// Author: Aman Bohra
//        ( bohraaman.blogspot.in)
// ROLL NO     : 007
// CLASS       : SE(COMPUTER)
// BATCH       : S1
// ASSIGNMENT NO.: 8
/* TITLE   :Write a C program to generate optimal Binary Search Tree for given data
//============================================================================*/
//Assignment No.: B8 - Optimal binary search tree 
 
#include <stdio.h> 
#define MAXKEYS (30) 
#define INFINITY 30000 
 
int n; // number of keys 
int key[MAXKEYS+1]; 
float p[MAXKEYS+1]; // probability of hitting key i 
float e[MAXKEYS+1][MAXKEYS+1]; // cost of subtree 
int r[MAXKEYS+1][MAXKEYS+1]; // root of subtree 
float w[MAXKEYS+1][MAXKEYS+1]; // weight 
 
void opttree() 

    int i,j,l,r1; 
    float t; 
 
    for (i=1;i<=n+1;i++) 
    { 
      e[i][i-1]=0;  // initialize cost and weight matrix to zero 
      w[i][i-1]=0; 
      } 
    for (l=1;l<=n;l++) // width of tree h=1 
    { 
 
        for(i=1;i<=n-l+1;i++) 
        { 
        j=i+l-1; 
        e[i][j]=INFINITY; 
        w[i][j]=w[i][j-1]+p[j]; 
 
        for(r1=i;r1<=j;r1++) 
        { 
            t=e[i][r1-1]+e[r1+1][j]+w[i][j]; 
            if(t<e[i][j]) 
            { 
            e[i][j]=t; 
            r[i][j]=r1; 
            } 
         } 
        } 
 
     } 

//this function prints subtree 
void construct_optimal_subtree(int i,int j, int r1, char *dir) 

     int t; 
     if(i<=j) 
     { 
    t=r[i][j]; 
    printf("\n %d is the %s Child of %d ",key[t],dir,key[r1]); 
    construct_optimal_subtree(i,t-1,t,"Left"); 
    construct_optimal_subtree(t+1,j,t,"Right"); 
     } 

// this function contructs binary tree. prints root 
void construct_BST() 

    int r1; 
    r1=r[1][n]; 
    printf("\n %d is the Root",key[r1]); 
    construct_optimal_subtree(1,r1-1,r1,"Left") ; 
    construct_optimal_subtree(r1+1,n,r1,"Right"); 


int main() 

    int i,j; 
    float prob=1.1; 
    printf("Enter the Total Number of Nodes"); 
    scanf("%d",&n); 
    for(i=1;i<=n;i++) 
    { 
 
        printf("\nEnter the Value of a Key: "); 
        scanf("%d",&key[i]); 
        printf("\n Enter its Probability of Success: "); 
        scanf("%f",&p[i]); 
        prob=prob-p[i]; 
        if(prob<0) 
        { 
            printf("\nTotal Probability increased by 1, Enter again:"); 
            prob=prob+p[i]; 
            i--; 
        } 
    } 
 
    opttree(); 
 
    printf("\nAverage Probe Length is %f\n",e[1][n]/w[1][n]); 
    printf("\nCost (e) Matrix is:\n"); 
    for(i=1;i<=n;i++) 
    { 
        for(j=1;j<=n;j++) 
        { 
            printf(" %.3f ",e[i][j]); 
        } 
        printf("\n"); 
    } 
    printf("\n Weight Matrix is: \n"); 
    for(i=1;i<=n;i++) 
    { 
        for(j=1;j<=n;j++) 
        { 
            printf(" %.3f ",w[i][j]); 
        } 
        printf("\n"); 
    } 
    printf("\n Root Matrix is:\n"); 
    for(i=1;i<=n;i++) 
    { 
        for(j=1;j<=n;j++) 
        { 
            printf(" %d ",r[i][j]); 
        } 
        printf("\n"); 
    } 
    construct_BST(); 
printf("\n");
    return 0; 

}
//============================================================================
// Author: Aman Bohra
//        ( bohraaman.blogspot.in)
// ROLL NO     : 007
// CLASS       : SE(COMPUTER)
// BATCH       : S1
// ASSIGNMENT NO.: 10
/* TITLE   :Write a C program to perform insert node, delete node and display operations on B tree.(on window platform)
//============================================================================*/

/* Binary tree implementation in CPP */
/* --------------------------------- */


#include <iostream.h>
#include <conio.h>
#include <stdlib.h>


struct node
{
node *left;
int value;
node *right;
};
node *curr=NULL;


int addnode(node *, node *);
int inorder(node *);
int preorder(node *);
int postorder(node *);


void main()
{
  char c;
  int v;
  clrscr();
  do
  {
  cout<<"
Select any one
";
  cout<<"
0 ->Exit
";
  cout<<"1 ->Add node
";
  cout<<"2 ->Inorder traversal
";
  cout<<"3 ->Preorder traversal
";
  cout<<"4 ->Postorder trversal : ";

  cin>>c;

  switch(c)
   {
    case '0':
                  exit(1);
    case '1':
                  node *temp;
                  temp = new node;
                  cout<<"  Enter the value of the node : ";
                  cin>>temp->value;
                  if(curr==NULL)
                   {
                    curr=new node;
                    curr->value=temp->value;
                    curr->left=NULL;
                    curr->right=NULL;
                    cout<<"  The root node is added";
                   }
                  else
                    v=addnode(curr,temp);
                  if(v==1)
                    cout<<"  The node is added to the left";
                  else if(v==2)
                    cout<<"  The node is added to the right";
                  else if(v==3)
                    cout<<"  The same value exists";
                  break;
    case '2':
                   v=inorder(curr);
                   if(v==0)
                   cout<<"The tree is empty";
                   break;
    case '3':
                   v=preorder(curr);
                   if(v==0)
                   cout<<" The tree is empty";
                   break;
    case '4':
                   v=postorder(curr);
                   if(v==0)
                   cout<<" The tree is empty";
                   break;
    default:
                   cout<<" Invalid entry";
                   break;
    }
   }while(c!='0');
   getch();
}


int addnode(node *fcurr, node *fnew )
{
  if(fcurr->value==fnew->value)
   {
     return 3;
   }
 else
   {
    if(fcurr->value > fnew->value)
     {
      if(fcurr->left != NULL)
                addnode(fcurr->left, fnew);
      else
                {
                fcurr->left = fnew;
                (fcurr->left)->left=NULL;
                (fcurr->left)->right=NULL;
                return 1;
                }
     }
    else
     {
      if(fcurr->right != NULL)
                addnode(fcurr->right, fnew);
      else
                {
                fcurr->right = fnew;
                (fcurr->right)->left=NULL;
                (fcurr->right)->right=NULL;
                return 2;
                }
     }
   }
}


int inorder(node *fincurr)
  {
    if(fincurr == NULL)
                return 0;
    else
     {
                 if(fincurr->left != NULL)
                  inorder(fincurr->left);
                  cout<<fincurr->value<<"    ";
                 if(fincurr->right != NULL)
                  inorder(fincurr->right);
      }
  }


int preorder(node *fprcurr)
  {
    if(fprcurr == NULL)
                return 0;
    else
     {
                cout<<fprcurr->value<<"    ";
                if(fprcurr->left != NULL)
                  preorder(fprcurr->left);
                if(fprcurr->right != NULL)
                  preorder(fprcurr->right);
      }
  }

int postorder(node *fpocurr)
  {
    if(fpocurr == NULL)
                return 0;
    else
     {
                if(fpocurr->left != NULL)
                  postorder(fpocurr->left);
                if(fpocurr->right != NULL)
                  postorder(fpocurr->right);
                  cout<<fpocurr->value<<"    ";
      }
  }

//============================================================================
// Author: Aman Bohra
//        ( bohraaman.blogspot.in)
// ROLL NO     : 007
// CLASS       : SE(COMPUTER)
// BATCH       : S1
// ASSIGNMENT NO.: 11
/* TITLE   :Tic-Tac- Toe gaming application using C++ Programming
//============================================================================*/
//Assignment No.: B11 - Tic Tac Toe Game

#include <iostream>

using namespace std;

char square[10] = {'o','1','2','3','4','5','6','7','8','9'};

int checkwin();

void board();

int main()
{
    int player = 1,i,choice;
    char mark;
    do
    {
        board();
        player=(player%2)?1:2;
        cout << "Player " << player << ", enter a number:  ";
        cin >> choice;
        mark=(player == 1) ? 'X' : 'O';
        if (choice == 1 && square[1] == '1')
            square[1] = mark;
        else if (choice == 2 && square[2] == '2')
            square[2] = mark;
        else if (choice == 3 && square[3] == '3')
            square[3] = mark;
        else if (choice == 4 && square[4] == '4')
            square[4] = mark;
        else if (choice == 5 && square[5] == '5')
            square[5] = mark;
        else if (choice == 6 && square[6] == '6')
            square[6] = mark;
        else if (choice == 7 && square[7] == '7')
            square[7] = mark;
        else if (choice == 8 && square[8] == '8')
            square[8] = mark;
        else if (choice == 9 && square[9] == '9')
            square[9] = mark;
        else
        {
            cout<<"Invalid move \n";
            player--;
        }
        i=checkwin();
        player++;
    }while(i==-1);
    board();
    if(i==1)
        cout<<"==>\aPlayer "<<--player<<" win \n\n";
    else
        cout<<"==>\aGame draw\n\n";
    return 0;
}

/*********************************************
    FUNCTION TO RETURN GAME STATUS
    1 FOR GAME IS OVER WITH RESULT
    -1 FOR GAME IS IN PROGRESS
    O GAME IS OVER AND NO RESULT
**********************************************/

int checkwin()
{
    if (square[1] == square[2] && square[2] == square[3])
        return 1;
    else if (square[4] == square[5] && square[5] == square[6])
        return 1;
    else if (square[7] == square[8] && square[8] == square[9])
        return 1;
    else if (square[1] == square[4] && square[4] == square[7])
        return 1;
    else if (square[2] == square[5] && square[5] == square[8])
        return 1;
    else if (square[3] == square[6] && square[6] == square[9])
        return 1;
    else if (square[1] == square[5] && square[5] == square[9])
        return 1;
    else if (square[3] == square[5] && square[5] == square[7])
        return 1;
    else if (square[1] != '1' && square[2] != '2' && square[3] != '3' &&
             square[4] != '4' && square[5] != '5' && square[6] != '6' &&
            square[7] != '7' && square[8] != '8' && square[9] != '9')
        return 0;
    else
        return -1;
}


/*******************************************************************
     FUNCTION TO DRAW BOARD OF TIC TAC TOE WITH PLAYERS MARK
********************************************************************/


void board()
{
    cout << "\n\n\tTic Tac Toe\n\n";
    cout << "Player 1 (X)  -  Player 2 (O)" << endl << endl;
    cout << endl;
    cout << "     |     |     " << endl;
    cout << "  " << square[1] << "  |  " << square[2] << "  |  " << square[3] << endl;
    cout << "_____|_____|_____" << endl;
    cout << "     |     |     " << endl;
    cout << "  " << square[4] << "  |  " << square[5] << "  |  " << square[6] << endl;
    cout << "_____|_____|_____" << endl;
    cout << "     |     |     " << endl;
    cout << "  " << square[7] << "  |  " << square[8] << "  |  " << square[9] << endl;
    cout << "     |     |     " << endl << endl;
}




//============================================================================
// Author: Aman Bohra
//        ( bohraaman.blogspot.in)
// ROLL NO     : 007
// CLASS       : SE(COMPUTER)
// BATCH       : S1
// ASSIGNMENT NO.: 12
/* TITLE   :Binary tree traversals BFS & DFS using Python classes
//============================================================================*/

//BFS.py

class Node(object):
  def __init__(self, value, left=None, right=None):
    self.value = value
    self.left = left
    self.right = right

def traverse(rootnode):
  thislevel = [rootnode]
  while thislevel:
    nextlevel = list()
    for n in thislevel:
      print n.value,
      if n.left: nextlevel.append(n.left)
      if n.right: nextlevel.append(n.right)
    print
    thislevel = nextlevel
//DFS.py

void printLevel(BinaryTree *p, int level) {
  if (!p) return;
  if (level == 1) {
    cout << p->data << " ";
  } else {
    printLevel(p->left, level-1);
    printLevel(p->right, level-1);
  }
}
 
void printLevelOrder(BinaryTree *root) {
  int height = maxHeight(root);
  for (int level = 1; level <= height; level++) {
    printLevel(root, level);
    cout << endl;
  }
}


//============================================================================
// Author: Aman Bohra
//        ( bohraaman.blogspot.in)
// ROLL NO     : 007
// CLASS       : SE(COMPUTER)
// BATCH       : S1
// ASSIGNMENT NO.: 14
/* TITLE   :Write a program in Python – to implement following operations on text file :- create , Read,
calculate the frequency of each vowel, Count the words, characters, lines, white space & special
characters, Write all the results into another text file
//============================================================================*/

*Assignment No:=B14*
def count_vowels():
    fin = open ('words.txt')
    count = 0
    vowels = ['aeiou']
    for line in fin:
        word = line.strip()
        if uses(word, vowels):
            count = count + 1
            print "There are", count ," words with a vowel."

def uses(word, vowels):
    for vowels in word:
        if vowels in vowels:
            return True
    return False

def count_words():                                
    fin = open ('words.txt')
    vowels = ['aeiou']
    for line in fin:
            word = line.strip()
            if uses(word, vowels):
                print word

count_vowels()
count_words()

#This is what returns in the shell when I run my code:

>>>There are 1 words with a vowel.
There are 2 words with a vowel.
There are 3 words with a vowel.
There are 4 words with a vowel.
There are 5 words with a vowel.
//============================================================================
// Author: Aman Bohra
//        ( bohraaman.blogspot.in)
// ROLL NO     : 007
// CLASS       : SE(COMPUTER)
// BATCH       : S1
// ASSIGNMENT NO.: 15
/* TITLE   :Write a program in C++ to implement hash table and handle the collision using linear probing
and chaining. (with or without replacement) for employee information Using the above implement direct access file mechanism.
//============================================================================*/

    /*

     * C++ Program to Implement Hash Tables with Linear Probing

     */

    #include <iostream>

    #include <cstdio>

    #include <cstdlib>

    using namespace std;

    const int TABLE_SIZE = 5;

     

    /*

     * HashNode Class Declaration

     */

    class HashNode

    {

        public:

            int key;

            int value;

            HashNode(int key, int value)

            {

                this->key = key;

                this->value = value;

            }

    };

     

    /*

     * DeletedNode Class Declaration

     */

    class DeletedNode:public HashNode

    {

        private:

            static DeletedNode *entry;

            DeletedNode():HashNode(-1, -1)

            {}

        public:

            static DeletedNode *getNode()

            {

                if (entry == NULL)

                    entry = new DeletedNode();

                return entry;

            }

    };

    DeletedNode *DeletedNode::entry = NULL;

    /*

     * HashMap Class Declaration

     */

    class HashMap

    {

        private:

            HashNode **htable;

        public:

            HashMap()

            {

                htable = new HashNode* [TABLE_SIZE];

                for (int i = 0; i < TABLE_SIZE; i++)

                {

                    htable[i] = NULL;

                }

            }

     

            ~HashMap()

            {

                for (int i = 0; i < TABLE_SIZE; i++)

                {

                    if (htable[i] != NULL && htable[i] != DeletedNode::getNode())

                        delete htable[i];

                }

                delete[] htable;

            }

            /*

             * Hash Function

             */

            int HashFunc(int key)

            {

                return key % TABLE_SIZE;

            }

            /*

             * Insert Element at a key

             */

            void Insert(int key, int value)

            {

                int hash_val = HashFunc(key);

                int init = -1;

                int deletedindex = -1;

                while (hash_val != init && (htable[hash_val]

                                == DeletedNode::getNode() || htable[hash_val]

                                != NULL && htable[hash_val]->key != key))

                {

                    if (init == -1)

                        init = hash_val;

                    if (htable[hash_val] == DeletedNode::getNode())

                        deletedindex = hash_val;

                    hash_val = HashFunc(hash_val + 1);

                }

                if (htable[hash_val] == NULL || hash_val == init)

                {

                    if(deletedindex != -1)

                        htable[deletedindex] = new HashNode(key, value);

                    else

                        htable[hash_val] = new HashNode(key, value);

                }

                if(init != hash_val)

                {

                    if (htable[hash_val] != DeletedNode::getNode())

                    {

                        if (htable[hash_val] != NULL)

                        {

                            if (htable[hash_val]->key == key)

                                htable[hash_val]->value = value;

                        }

                    }

                    else

                        htable[hash_val] = new HashNode(key, value);

                }

            }

            /*

             * Search Element at a key

             */

            int Search(int key)

            {

                int hash_val = HashFunc(key);

                int init = -1;

                while (hash_val != init && (htable[hash_val]

                                == DeletedNode::getNode() || htable[hash_val]

                                != NULL && htable[hash_val]->key != key))

                {

                    if (init == -1)

                        init = hash_val;

                    hash_val = HashFunc(hash_val + 1);

                }

                if (htable[hash_val] == NULL || hash_val == init)

                    return -1;

                else

                    return htable[hash_val]->value;

            }

            /*

             * Remove Element at a key

             */

            void Remove(int key)

            {

                int hash_val = HashFunc(key);

                int init = -1;

                while (hash_val != init && (htable[hash_val]

                                == DeletedNode::getNode() || htable[hash_val]

                                != NULL && htable[hash_val]->key != key))

                {

                    if (init == -1)

                        init = hash_val;

                    hash_val = HashFunc(hash_val + 1);

                }

                if (hash_val != init && htable[hash_val] != NULL)

                {

                    delete htable[hash_val];

                    htable[hash_val] = DeletedNode::getNode();

                }

            }

    };

     

    /*

     * Main Contains Menu

     */

    int main()

    {

        HashMap hash;

        int key, value;

        int choice;

        while(1)

        {

            cout<<"\n----------------------"<<endl;

            cout<<"Operations on Hash Table"<<endl;

            cout<<"\n----------------------"<<endl;

            cout<<"1.Insert element into the table"<<endl;

            cout<<"2.Search element from the key"<<endl;

            cout<<"3.Delete element at a key"<<endl;

            cout<<"4.Exit"<<endl;

            cout<<"Enter your choice: ";

            cin>>choice;

            switch(choice)

            {

            case 1:

                cout<<"Enter element to be inserted: ";

                cin>>value;

                cout<<"Enter key at which element to be inserted: ";

                cin>>key;

                hash.Insert(key, value);

                break;

            case 2:

                cout<<"Enter key of the element to be searched: ";

                cin>>key;

                if(hash.Search(key) == -1)

                {

                    cout<<"No element found at key "<<key<<endl;

                    continue;

                }

                else

                {

                    cout<<"Element at key "<<key<<" : ";

                    cout<<hash.Search(key)<<endl;

                }

                break;

            case 3:

                cout<<"Enter key of the element to be deleted: ";

                cin>>key;

                hash.Remove(key);

                break;

            case 4:

                exit(1);

            default:

               cout<<"\nEnter correct option\n";

           }

        }

        return 0;

    }



/*
OUTPUT

----------------------
Operations on Hash Table
 
----------------------
1.Insert element into the table
2.Search element from the key
3.Delete element at a key
4.Exit
Enter your choice: 1
Enter element to be inserted: 100
Enter key at which element to be inserted: 1
 
----------------------
Operations on Hash Table
 
----------------------
1.Insert element into the table
2.Search element from the key
3.Delete element at a key
4.Exit
Enter your choice: 1
Enter element to be inserted: 300
Enter key at which element to be inserted: 3
 
----------------------
Operations on Hash Table
 
----------------------
1.Insert element into the table
2.Search element from the key
3.Delete element at a key
4.Exit
Enter your choice: 1
Enter element to be inserted: 500
Enter key at which element to be inserted: 5
 
----------------------
Operations on Hash Table
 
----------------------
1.Insert element into the table
2.Search element from the key
3.Delete element at a key
4.Exit
Enter your choice: 1
Enter element to be inserted: 600
Enter key at which element to be inserted: 6
 
----------------------
Operations on Hash Table
 
----------------------
1.Insert element into the table
2.Search element from the key
3.Delete element at a key
4.Exit
Enter your choice: 1
Enter element to be inserted: 800
Enter key at which element to be inserted: 8
 
----------------------
Operations on Hash Table
 
----------------------
1.Insert element into the table
2.Search element from the key
3.Delete element at a key
4.Exit
Enter your choice: 1
Enter element to be inserted: 1000
Enter key at which element to be inserted: 10
 
----------------------
Operations on Hash Table
 
----------------------
1.Insert element into the table
2.Search element from the key
3.Delete element at a key
4.Exit
Enter your choice: 2
Enter key of the element to be searched: 3
Element at key 3 : 300
 
----------------------
Operations on Hash Table
 
----------------------
1.Insert element into the table
2.Search element from the key
3.Delete element at a key
4.Exit
Enter your choice: 2
Enter key of the element to be searched: 7
No element found at key 7
 
----------------------
Operations on Hash Table
 
----------------------
1.Insert element into the table
2.Search element from the key
3.Delete element at a key
4.Exit
Enter your choice: 2
Enter key of the element to be searched: 10
Element at key 10 : 1000
 
----------------------
Operations on Hash Table
 
----------------------
1.Insert element into the table
2.Search element from the key
3.Delete element at a key
4.Exit
Enter your choice: 3
Enter key of the element to be deleted: 5
 
----------------------
Operations on Hash Table
 
----------------------
1.Insert element into the table
2.Search element from the key
3.Delete element at a key
4.Exit
Enter your choice: 2
Enter key of the element to be searched: 6
Element at key 6 : 600
 
----------------------
Operations on Hash Table
 
----------------------
1.Insert element into the table
2.Search element from the key
3.Delete element at a key
4.Exit
Enter your choice: 2
Enter key of the element to be searched: 5
No element found at key 5
 
----------------------
Operations on Hash Table
 
----------------------
1.Insert element into the table
2.Search element from the key
3.Delete element at a key
4.Exit
Enter your choice: 1
Enter element to be inserted: 700
Enter key at which element to be inserted: 7
 
----------------------
Operations on Hash Table
 
----------------------
1.Insert element into the table
2.Search element from the key
3.Delete element at a key
4.Exit
Enter your choice: 2
Enter key of the element to be searched: 7
Element at key 7 : 700
 
----------------------
Operations on Hash Table
 
----------------------
1.Insert element into the table
2.Search element from the key
3.Delete element at a key
4.Exit
Enter your choice: 4
 */
Group-C




//============================================================================
// Author: Aman Bohra
//        ( bohraaman.blogspot.in)
// ROLL NO     : 007
// CLASS       : SE(COMPUTER)
// BATCH       : S1
// ASSIGNMENT NO.: C1
/* TITLE   :Write bubble Sort program using Python programming
//============================================================================*/


class Bubble:
    #constructor defined
    def __init__(self,myarr):
        self.myarr=myarr

def bubbleSort(self):
    swaps=True
    while swaps:
        swaps=False
        for i in range(len(self.myarr)-1):
            if self.myarr[i]>self.myarr[i+1]:
                swaps=True
                temp=self.myarr[i]
                self.myarr[i]=self.myarr[i+1]
                self.myarr[i+1]=temp
                print(self.myarr)

def display(self):
    print(self.myarr)

myarr=[70,20,10,40,30,60,50]
print("\n\t Program for Bubble Sort")
obj=Bubble(myarr)
obj.bubbleSort()
obj.display()

-------------------------------------------------------------------------

//output
//#Python Program to sort the numbers using Bubble Sort
#Total Numbers: 5
#Enter 1 Number:  5
#Enter 2 Number:  4
#Enter 3 Number:  3
#Enter 4 Number:  2
#Enter 5 Number:  1
#After iteration:  1
#4 3 2 1 5 /***  2 biggest number(s) is(are) pushed to the end of the array***/
#After iteration:  2
#3 2 1 4 5 /***  3 biggest number(s) is(are) pushed to the end of the array***/
#After iteration:  3
#2 1 3 4 5 /***  4 biggest number(s) is(are) pushed to the end of the array***/
#After iteration:  4
#1 2 3 4 5 /***  5 biggest number(s) is(are) pushed to the end of the array***/
#The sorted array is:  1 2 3 4 5




------------------------------------------------------------------------------------------
OSA Oral :
-------------------------------------------------------------------------------------------

OSA Material..
------------------------------------------------------------------------------------------
MA Oral :
-------------------------------------------------------------------------------------------

8086 practice program

Assignment 01
Assignment 02
Assignment 03
Assignment 04
Assignment 05
Assignment 06
Assignment 07
Assignment 08
Assignment 09
Assignment 10
Assignment 11
Assignment 12
Assignment 13

MA PRACTICAL
------------------------------------------------------------------------------------------
DELD Program's :
-------------------------------------------------------------------------------------------


most of them have question 
"How to write on main sheet of the file of which we are making ready for Sub-mission.....??"
For them @m@n Voice is
"that presentation doesn't really matter  much just focus on the concept..............
Your primary objective should be knowing the concept and  making it implementing  in any way
take my example


 Experiment Number 4 :
















Soft skills writeups..



ASSIGNMENT NO: -1                                                        DATE:-
AIM: Write assignment on SWOT Analysis.
OBJECTIVE: -To examine the internal and external factors that help or hinder you in achieving each of your goals.

THEORY:-

·         SWOT Analysis of People:

SWOT is an acronym that stands for strengths, weaknesses, opportunities and threats. SWOT analysis of people occurs when you make an assessment based on your observations about the strengths, weaknesses, opportunities and threats presented by people with whom you interact. It is often used in business management. SWOT analysis of people will help you make the most of your professional relationships.

·         Strengths

When examining the strengths of a person or group, think about internal things such as skills, personality traits, experience and education. Ask yourself what situations bring out the best in the person or group and what sets them apart from competition.

·         Weaknesses

Identifying the weaknesses of the person or group can be done by internal qualities that can be improved. Perhaps the subject of your analysis has trouble with focusing, requires more training or needs to work on his interpersonal skills.
A weakness is the opposite of a strength.it is an internal negative aspect that is under the control of the individual. Like strengths, weaknesses can be related to education, knowledge and experiences that the individual has.
·         Opportunities
Opportunities are positive external conditions that the individual does not control, but that he can take advantage of. Pay special attention to the person's strengths when considering opportunities for him. For example, if the person has great leadership skills, you might consider leadership opportunities for him in your business. Consider any area where the person can help improve the business as a potential opportunity. Make a list of all the opportunities to consider for the person in question.

·         Threats

Threats are negative external aspects that the individual does not control but that can affect her negatively. These might include changes to your business overall or to the individual's job responsibilities. Consider potential threats in light of the person's weaknesses.
·         A Personal SWOT Example
ร˜  Strengths
o   I'm very creative. I often impress clients with a new perspective on their brands.
o   I communicate well with my clients and team.
o   I have the ability to ask key questions to find just the right marketing angle.
o   I'm completely committed to the success of a client's brand.
ร˜  Weaknesses
o   I have a strong, compulsive need to do things quickly and remove them from my "to do" list, and sometimes the quality of my work suffers as a result.
o   This same need to get things done also causes me stress when I have too many tasks.
o   I get nervous when presenting ideas to clients, and this fear of public speaking often takes the passion out of my presentations.
ร˜  Opportunities
o   One of our major competitors has developed a reputation for treating their smaller clients poorly.
o   I'm attending a major marketing conference next month. This will allow for strategic networking, and also offer some great training seminars.
o   Our art director will go on maternity leave soon. Covering her duties while she's away would be a great career development opportunity for me.
ร˜  Threats
o   Simon, one of my colleagues, is a much stronger speaker than I am, and he's competing with me for the art director position.
o   Due to recent staff shortages, I'm often overworked, and this negatively impacts my creativity.
o   The current economic climate has resulted in slow growth for the marketing industry. Many firms have laid off staff members, and our company is considering further cutbacks.
 Conclusion : Thus,we conclude how to
ร˜  Build on your strengths.
ร˜  Minimize your weaknesses.
ร˜  Seize opportunities.
ร˜  Counteract threats.
                       
     Experiment Perform Satisfactorily?                                                    Yes / No
     Assignment submitted timely along with experiment result               Yes / No
     Date on which experiment was performed                 …………………..
Signature of Staff
ASSIGNMENT NO: -2                                                                    DATE:-
AIM: - Write assignment on Presentation Skill.

OBJECTIVES: -

  • To establish credibility with your audience.
  • To communicate information clearly to your audience.
  • To persuade and/or influence your audience.
THEORY:-

·         What is a Presentation?

A presentation is a means of communication which can be adapted to various speaking situations, such as talking to a group, addressing a meeting or briefing a team. To be effective, step-by-step preparation and the method and means of presenting the information should be carefully considered.

·         Preparing Your Presentation

Preparation is the most important part of making a successful presentation.  This is the crucial foundation and there should be no short-cuts.

ร˜  Purpose of your presentation

Imagine that you have been scheduled to speak to a group. An important question for you to review is “Why am I delivering this presentation?”  Don’t answer, “Because I was asked.” Instead ask why does this group need to hear from you? What message is so important that you must take their time to speak to them? You must be clear on the purpose of your speech before you can write it. Please don’t give a speech just because you are the boss. Don’t waste their time and embarrass yourself. Have something worthwhile to say. If you start by knowing what you want to happen then you will begin to create an effective speech.
ร˜  Your audience is the reason you are there
Understand your audience. What do they want? Why would they listen to you? If you want to reach them with your presentation you must reach them through their needs. While you are talking they are asking themselves, “What’s in it for us?” If you have not spoken to this group before, interview a few of them before your presentation. Mention the names of some audience members during your presentation. It will help you connect with the group.
ร˜  Design your presentation backwards
The most common way to write your speech is to start at the beginning and write to the end. That is not an effective way to write a speech. Instead write the speech backwards. Start with the destination and work back to the opening. You will write your speech faster and clearer if you start with the end in mind. Know your purpose. Write the closing line that hammers home your message. Then write the points to support that close. Then write your opening that launches you into that presentation. Designing your speech is also a set of communication skills.

ร˜  Presentation Structure

There are many presentation structures that you can choose from. When you speak to a business group the most effective approach is to state your conclusions first, the actions required then follow with supporting information. That would be an effective business speech.
 The most boring and ineffectual presentation style to use with a business group is the scientific method that many of us learned in school. The scientific method starts with a problem, followed by a hypothesis, a method, results and conclusion. That sounds logical but most people in business today do not have the patience to listen to that litany.

ร˜  Question & Answer structure

Another simple presentation structure that works is to tell your audience that you will answer the most common questions you have heard. Then you state the question and answer it. This is one of the easiest ways to give a speech. It sounds like a conversation and you will find it easier to remember. All you need to remember are the questions because you already know the answers. The best speech feels like a conversation.

·         TIPS ON MAKING PRESENTATIONS

As part of an extended interview/selection centre you may be asked to give a short presentation. Usually you choose the topic from a list which may include your hobbies, a recent holiday, a current affairs topic or one of your achievements, or sometimes you may be asked to make a presentation on a case study you have previously done as part of the extended interview. The purpose is not to test your subject knowledge, but to see how well you can speak in public. Typically you will be asked to talk for five minutes, and will be given 20 or 30 minutes beforehand to prepare.

 

BASIC TIPS

ร˜  Dress smartly: don't let your appearance distract from what you are saying.
ร˜  Smile. Don't hunch up and shuffle your feet. Have an upright posture. Try to appear confident and enthusiastic.
ร˜  Say hello and smile when you greet the audience: your audience will probably look at you and smile back: an instinctive reaction.
ร˜  Speak clearly, firmly and confidently as this makes you sound in control. Don't speak
ร˜  too quickly: you are likely to speed up and raise the pitch of your voice when nervous. Give the audience time to absorb each point. Don't talk in a monotone the whole time. Lift your head up and address your words to someone near the back of audience. If you think people at the back can't hear, ask them.
ร˜  Use silence to emphasize points. Before you make a key point pause.this tells the audience that something important is coming. It's also the hallmark of a confident speaker as only these are happy with silences. Nervous speakers tend to gabble on trying to fill every little gap.
ร˜  Keep within the allotted time for your talk.
ร˜  Eye contact is crucial to holding the attention of your audience. Look at everyone in the audience from time to time, not just at your notes or at the PowerPoint slides. Try to involve everyone, not just those directly in front of you.
ร˜  You could try to involve your audience by asking them a question.
ร˜  Don't read out your talk, as this sounds boring and stilted, but refer to brief notes jotted down on small (postcard sized) pieces of card. Don't look at your notes too much as this suggests insecurity and will prevent you making eye contact with the audience.
ร˜  It’s OK to use humour, in moderation, but better to use anecdotes than to rattle off a string of jokes.
ร˜  Take along a wristwatch to help you keep track of time – the assessor may cut you off as soon as you have used the time allocated, whether or not you have finished.
ร˜  It can be very helpful to practise at home in front of a mirror. You can also record your presentation and play it back to yourself: don't judge yourself harshly when you replay this - we always notice our bad points and not the good when hearing or seeing a recording or ourselves! Time how long your talk takes. Run through the talk a few times with a friend.
ร˜  It's normal to be a little nervous. This is a good thing as it will make you more energized. Many people have a fear of speaking in public. Practicing will make sure that you are not too anxious. In your mind, visualise yourself giving a confident successful performance. Take a few deep slow breaths before your talk starts and make a conscious effort to speak slowly and clearly. Research by T Gilovich (Cornell University) found that people who feel embarrassed are convinced their mistakes are much more noticeable than they really are: we focus on our own behaviour more than other people do and so overestimate it's impact. This is called the spotlight effect. If you make a mistake, don't apologise too much, just briefly acknowledge the mistake and continue on.
ร˜  Build variety into the talk and break it up into sections: apparently, the average person has a three minute attention span!
·         Conclusion: Thus we study how to prepare for, and the dynamics of effective presentations
     Experiment Perform Satisfactorily?                                                    Yes / No
     Assignment submitted timely along with experiment result               Yes / No
     Date on which experiment was performed                 …………………..
Signature of Staff
 ASSIGNMENT NO: -3                                           DATE:-
AIM: - Study write up on letter Writing.

OBJECTIVE: -

ร˜  To gain an overview of the types of letters and the steps involved in the letter writing process
THEORY:-
Letter Writing:
·         Rules for Writing Formal Letters in English
In English there are a number of conventions that should be used when writing a formal or business letter. Furthermore, you try to write as simply and as clearly as possible, and not to make the letter longer than necessary. Remember not to use informal language like contractions.
ร˜  Addresses:
o   Your Address: The return address should be written in the top right-hand corner of the letter.
o   The Address of the person you are writing to:
The inside address should be written on the left, starting below your address.
o   Date:
Different people put the date on different sides of the page. You can write this on the right or the left on the line after the address you are writing to. Write the month as a word.
ร˜  Salutation or greeting:
o   Dear Sir or Madam,
If you do not know the name of the person you are writing to, use this. It is always advisable to try to find out a name.
o   Dear Mr Jenkins,
If you know the name, use the title (Mr., Mrs., Miss or Ms, Dr, etc.) and the surname only. If you are writing to a woman and do not know if she uses Mrs. or Miss, you can use Ms, which is for married and single women.
ร˜  Ending a letter:
o   Yours faithfully
If you do not know the name of the person, end the letter this way.
o   Yours sincerely
If you know the name of the person, end the letter this way.
o   Your signature
Sign your name, then print it underneath the signature. If you think the person you are writing to might not know whether you are male of female, put you title in brackets after your name.
·         Formal Letter:
Topic: Sample letter to your father telling him about your studies and daily routine.
                                                                                                            Flat No-6,
                                                                                                            Shruti nivas
                                                                                                            Nashik-422004
                                                                                                            24June2013
My dear father,
I have your blessings. I am quite well and hope you too would be fine. You have asked me about my daily routine.
I get up early in the morning. I study for two hours. Then I go out for a morning walk. I take four rounds of the park. I stroll in the park. When I return, I take milk and refreshment. Again I start my studies and continue for two hours. I study English, Science and Mathematics in the morning. Then I go to school and attend my regular classes. I take my lunch during the recess.
I am very sincere to my studies. I secured good marks in the first terminal and hope to do all the better in the final. My school breaks up at 3 p.m. On my return, I take a little rest. I go to play in the evening. I play for an hour with my friends. In evening I take snacks and tea. I once again resume my studies in late evening. I study for three hours. I do my homework in time. I am working hard to fulfill your expectations.
Please convey my best compliments to mother.
Yours affectionately,
Ridhi Chauhan
Application letter:
Topic:Sample Leave Application Letter
                                                                                                                                                                        Date:24 june 2013
To,
Manas Sethia
Orchid Pvt. Ltd.
HR Manager,
Sub: Application for Leave
Respected Sir/Madam (whichever is applicable)
I would like to apply for 10-days leave as I have to visit my parents in my hometown. My father is sick and has been hospitalized recently. I need to go there to look after him and be there with my family. So I would request you to grant me leave starting from 17th September, 2012 and ending on 26th September, 2012.
I would be highly obliged if my leave request is granted.
Yours faithfully
R. Ramakrishna
Conclusion:By this practical,we get the knowledge of letter writing in proper way and how to use it and where to use it.
     Experiment Perform Satisfactorily?                                                    Yes / No
     Assignment submitted timely along with experiment result               Yes / No
     Date on which experiment was performed                 …………………..
Signature of Staff
 ASSIGNMENT NO: -4                                               DATE:-
AIM: - Study write up on listening Skill.
OBJECTIVE:
  •  listen effectively in a variety of situations for a variety of purposes.
  • practice the behaviours of eff ective, active listeners.
  • assess strengths in listening and set goals for future growth.
THEORY:-              
Listening skills
·         Need of Good Listening Skills
Good listening skills make workers more productive. The ability to listen carefully will allow you to:
ร˜  Better understand assignments and what is expected of you;
ร˜  Build rapport with co-workers, bosses, and clients;
ร˜  Show support;
ร˜  Work better in a team-based environment;
ร˜  Resolve problems with customers, co-workers, and bosses;
ร˜  Answer questions; and
ร˜  Find underlying meanings in what others say.

What does it mean to really listen?

·         Real listening is an active process that has three basic steps.
ร˜  Hearing: Hearing just means listening enough to catch what the speaker is saying. For example, say you were listening to a report on zebras, and the speaker mentioned that no two are alike. If you can repeat the fact, then you have heard what has been said.
ร˜  Understanding: The next part of listening happens when you take what you have heard and understand it in your own way. Let's go back to that report on zebras. When you hear that no two are alike, think about what that might mean. You might think, "Maybe this means that the pattern of stripes is different for each zebra."
ร˜  Judging: After you are sure you understand what the speaker has said, think about whether it makes sense. Do you believe what you have heard? You might think, "How could the stripes to be different for every zebra? But then again, the fingerprints are different for every person. I think this seems believable."

·         Tips for being a good listener

ร˜  Give your full attention on the person who is speaking. Don't look out the window or at what else is going on in the room.
ร˜  Make sure your mind is focused, too. It can be easy to let your mind wander if you think you know what the person is going to say next, but you might be wrong! If you feel your mind wandering, change the position of your body and try to concentrate on the speaker's words.
ร˜  Let the speaker finish before you begin to talk. Speakers appreciate having the chance to say everything they would like to say without being interrupted. When you interrupt, it looks like you aren't listening, even if you really are.
ร˜  Let yourself finish listening before you begin to speak! You can't really listen if you are busy thinking about what you want say next.
ร˜  Listen for main ideas. The main ideas are the most important points the speaker wants to get across. They may be mentioned at the start or end of a talk, and repeated a number of times. Pay special attention to statements that begin with phrases such as "My point is..." or "The thing to remember is..."
ร˜  Ask questions. If you are not sure you understand what the speaker has said, just ask. It is a good idea to repeat in your own words what the speaker said so that you can be sure your understanding is correct. For example, you might say, "When you said that no two zebras are alike, did you mean that the stripes are different on each one?"
ร˜  Give feedback. Sit up straight and look directly at the speaker. Now and then, nod to show that you understand. At appropriate points you may also smile, frown, laugh, or be silent. These are all ways to let the speaker know that you are really listening. Remember, you listen with your face as well as your ears!
·         Simple listening technique
  1. Listen
ร˜  Don’t interrupt
ร˜  Let the speaker finish
ร˜  Concentrate on what is being said and how it is being said
ร˜  Make notes if this helps
ร˜  Show the speaker that you are listening
  1. Question
ร˜  Check understanding
  1. Summarise
ร˜  Paraphrase what the speaker has just told you.
·         DO’s
ร˜  Be mentally prepared to listen
ร˜  Evaluate the speech not the speaker
ร˜  Be unbiased to the speaker by depersonalizing your feelings
ร˜  Fight distractions by closing off sound sources
ร˜  Be open minded
ร˜  Ask questions to clarify and not to overshadow intelligence
ร˜  Paraphrase from time to time
ร˜  Send appropriate non-verbal signals time to time
·         Don’ts:
ร˜  Not to pay undue emphasis on vocabulary as you can use the context to understand the meaning
ร˜  Not to pay too much attention to the accessories and clothing of the speaker
ร˜  Not to prepare your responses while the speaker is speaking
ร˜  Avoid preconceptions and prejudices
ร˜  Not to get distracted by outside influences
ร˜  Not to interrupt too often
ร˜  Not to show boredom
Conclusion:In this way, we conclude how to become a good listener.
     Experiment Perform Satisfactorily?                                                    Yes / No
     Assignment submitted timely along with experiment result               Yes / No
     Date on which experiment was performed                 …………………..
Signature of Staff
ASSIGNMENT NO: -5                                                               DATE:-
AIM: - Study write up on Group Discussion.
OBJECTIVE: -
  • Produce a range of options or solutions, addressing a particular problem or an issue.
  • Generate a pile of ideas by examining issues in greater depth, looking at different dimensions of these issues.
  • Broaden the outlook of the participants through cross-fertilization and exposure to new and different experiences and ideas and enrich their understanding of the issues under discussion.
  • Develop their skills in interpersonal communication and in expressing their views in a clear and succinct manner.
  • Effective means of changing attitudes through the influence of peers in the group
  • Valuable means of obtaining feedback for the training team on verbal skills, motivation level and personal traits of the participants and characteristics of the group.
THEORY:-              
·         Group Discussion
ร˜  It refers to the situation where a particular number of people (three to eight) meet face to face and through free oral interaction, originate, share and discuss ideas to arrive at a decision or solution to a problem.
ร˜  Group discussions are used for decision-making and problem solving.
ร˜  They are also used widely as a personality test for evaluating several candidates simultaneously.
·         Structure and Objective:
ร˜  A group of candidates is given a topic or case for discussion.
ร˜  Normally groups of eight to ten candidates formed into a leaderless group, and are given a specific situation to analyze and discuss within a given time limit
·         The four components generally evaluated in a group discussion are:
ร˜  Knowledge
ร˜  Communication skills
ร˜  Group behavior
Communication Skills : Candidate assessed in terms of:
ร˜  Active listening
ร˜  Clarity of thought and expression
ร˜  Appropriateness of body language
ร˜  Lucidity
ร˜  Tone: Quality or character of the voice expression a particular feeling or mood
ร˜  Voice: Power of speech
ร˜  Articulation: Act of speaking or expressing an idea in words
ร˜  Fluency: Speaking or writing in an easy, flowing style
ร˜  Modulation: Variations in rate, tone, or volume of voice
ร˜  Good delivery: The ideas expressed fluently in the right voice, right tone, and right articulation.
ร˜  It isn’t sufficient to have ideas. They have to be expressed effectively.
ร˜  Fluency and accuracy in use of language free from grammatical errors.
·         Effective Use of Body Language:
ร˜  Looking attentively at the speaker and nodding
ร˜  While speaking, ensuring no one is ignored. Looking at everybody.
ร˜  Avoiding overt gestures
ร˜  Avoiding pointing out fingers
ร˜  Avoiding monotonous posture by shifting slightly in the chair or placing arm on the back of your chair
ร˜  Not showing interest or dislike in the topic.
ร˜  Even if one does not like the topic he should try to develop interest and reveal interest and enthusiasm through appropriate facial expression.
·         Group Behavior ( Team Spirit):
ร˜  Group behavior is reflected in ability to interact with other members of the group on brief acquaintance.
ร˜  Emotional maturity and balance promotes good interpersonal relationships. One is expected to be more people centric and less ego centric.
ร˜  Remaining objective, empathetic, and non-threatening, and behaving maturely as a good team player
·         Essence:
ร˜  Consistency participation
ร˜  Keenness in listening and observing
ร˜  Time sharing and orderly conduct
ร˜  Ability to handle turbulent situations
ร˜  Ability to cut excessively exuberant participants down to size
ร˜  Ability to dominate the proceedings without bullying others
ร˜  Avoiding personal comments
·         Dos:
ร˜  Sitting comfortably
ร˜  Listening to topic
ร˜  Organizing ideas
ร˜  Speaking at the earliest
ร˜  Identifying supporters/ opponents
ร˜  Keeping track of time
ร˜  Sharing time fairly
ร˜  Maintaining eye contact
ร˜  Taking notes
ร˜  Aiming for summary if needed
·         Don’ts:
ร˜  Being in a hurry
ร˜  Being silent
ร˜  Dominating vocally/physically
ร˜  Assuming role of chairman
ร˜  Introducing topic
ร˜  Taking extreme stance
ร˜  Looking at faculty
ร˜  Moving excessively
ร˜  Throwing all ideas at one shot
ร˜  Speaking fast
ร˜  Digressing
ร˜  Indulging in ill conversation
ร˜  Paying attention to bull dozers
ร˜  Using slang
ร˜  Getting emotional
·         Benefits in Group discussion:
ร˜  Stimulation of thinking in a new way.
ร˜  Expansion of knowledge
ร˜  Understanding of your strength and weakness.
ร˜  Your true personality is revealed and qualities of leadership crystallize
ร˜  provides  chance to Expose
ร˜  Language skills
ร˜  Academic knowledge
ร˜  Leadership skills
ร˜  people handling skills
ร˜  Team work
Conclusion:-From group discussion we get confidence,sense of humour,presence of mind and thinking ability which will be very helpful for over future.
     Experiment Perform Satisfactorily?                                                    Yes / No
     Assignment submitted timely along with experiment result               Yes / No
     Date on which experiment was performed                 …………………..
Signature of Staff
ASSIGNMENT NO: -6                                                        DATE:-
AIM: - Study write up on Resume Writing.
OBJECTIVE: - To provide a summary of your skills, abilities and accomplishments.

THEORY:-

·         How to write a resume
A resume - sometimes called a curriculum vitae or CV - is a summary of your education, training, work experience and skills. A good resume demonstrates how your skills and abilities match up with the requirements of a job.
·         How Long Should a Resume Be?
A resume isn't an exhaustive list. If it's too long it probably won't get read. The best resumes are usually no longer than one or two pages.
If you need to go over two pages that are okay, but make sure everything you include is necessary to explain how good a fit you are for the job.
The worst thing to do is to pad out your resume. There's nothing wrong with a one-page resume, as long as it has all of the relevant information on it. More is not necessarily better.
·         Do I Need to Change My Resume Every Time?
You need to change your resume for every job application so that it lists the skills and experiences that are most relevant to the job you're applying for. Not every job will have the same set of requirements, but every resume you send out needs to be 100% relevant to the requirements of that job.
The point of a resume is to convince a recruiter or employer you're worth interviewing. A tailored resume makes that case better than a generic one, so it's worth the extra time.
·         How to Tailor Your Resume
First, find out what the job requires. If you found out about the job from a job listing, the key requirements or skills should be in the add. There may also be a position description, which is a document that outlines exactly what kind of skills and experience a job requires. If you found out about the job from your networks, ask the person who told you about it what skills and experience the employer is looking for.
If you feel like you need more information you can always contact the recruiter or employer and ask them. There should be a phone number or email address either on their website or the job listing.
Be polite and introduce yourself when you make contact. Showing you have the initiative and ability to research the job can make a good impression.
Next, make a list of the job requirements and think about jobs that you've done or experiences you've had that required those skills. These are the experiences you need to put on your resume. Anything that doesn't match up to those job requirements should not be included.
·         You Should Definitely Include on Your Resume:
ร˜  Personal Details
Put your full name and contact details on your resume, including your address, telephone number(s) and email address.
Make sure you use a professional-sounding email address. Email addresses like bigbooty@partytime.net don't create a great impression. If you haven't got a professional-sounding email, get one. Make it as close to your real name as possible - something like emilybenbow@hmail.com is ideal.
The best place to put personal details is in the header of your resume. That way it will appear on every page. This will also leave room for (and focus attention on) the most important stuff: proof you have the skills and experience for the job.
ร˜  Education and Training
This is a summary of your education and training history, starting with your most recent studies. Make sure that you include all training that's relevant to the job you're applying for, including any on-the-job training you've done.
If you haven't done much study or training, just put down what you have done. Don't pad things out with things like First Aid or Responsible Service of Alcohol, unless they're relevant to the job you're applying for. More is not always better.
ร˜  Employment History
Generally speaking it's best to start with your most recent job and work backwards, listing:
  • The name of the employer
  • Your job title
  • The dates you worked there
  • Your duties and responsibilities
  • Any major achievements while you worked there
Make sure that each job that you list demonstrates how well you are suited for the job you're applying for. Emphasis  the skills that are asked for by the recruiter or employer.
If you've done a lot of different kinds of jobs, you could list your work experience in a way that links those jobs to the job you're applying for. You could list the jobs in related fields first, under "Relevant Work Experience" and then briefly list the other jobs under "Other Work Experience".
You can also include any work experience or volunteer work that you've done. Only include volunteering and work experience that's relevant, though. No sense mentioning that you volunteer at the RSPCA shelter if you're going for a job in IT!
Remember - a short resume is a good resume. More is not always better.
ร˜  Page Numbers
Make sure your resume has page numbers on it, even if it's just one page. Page numbers on a one-page resume make sure the recruiter or employer knows they're looking at the whole thing. Page numbers on a two-page (or three-page) resume ensure that if a page is missing, they go looking for it so they don't miss out on any information about you.
·         You Should Maybe Include on Your Resume:
Here's a few things that you should consider including on your resume - but only if they show you're a good fit for the job.
ร˜  Professional Profile
A professional profile directly links the job's requirements to your skills. It's kind of like a mini-cover letter, designed to grab a recruiter or employer's attention and encourage them to read on. Some recruiters may jump straight to resumes without reading cover letters, especially when there are a lot of applications to read. A professional profile can help to grab their attention right at the start.
You can create a professional profile by asking the following questions:
  • What skills and abilities can I bring to this employer?
  • What excites me about this role?
  • How can I show that there is a link between the skills listed on my resume and this job?
If you include a professional profile, make sure it's only a few short bullet points and make sure that it stays relevant to the requirements of the job.
ร˜  Other Experience
This is a list of your activities outside of work and study. A list of relevant interests can show how well your suited to the job. You might include clubs you're a member of or sports you play.
If you include interests, make sure they're relevant to the job you are applying for. No sense mentioning the astronomy club in an application for an electrician apprenticeship.
·         What You Should NOT Include on Your Resume
Here are a few things that you don't have to include on your resume, although there are some circumstances when including some of the following information might be a good idea.
ร˜  Other Personal Information
Discrimination in employment is a real concern. You're not obliged to provide any personal information on your resume over and above your name and contact details. This means that you don't have to provide:
  • Your date of birth
  • Your marital status
  • Your gender
  • Any languages you speak
  • Any disabilities that you have
  • Any other personal information
A  possible exception to this when providing this information would be an advantage. For example, if the employer is looking for someone young, or a female applicant, or an applicant who comes from a particular background. In this situation consider including such information if you think it would strengthen your application.
·         Career Objective
Career objective statements are a general statement about your career goals. They don't really help to prove you're a good choice for the job. They risk distracting from the important information on your resume.
·         Referees (or Written References)
It is no longer standard practice to provide referees or written references as part of a job application. You should still find some people to be your referee, but you don't need to include their details on your resume. Instead, simply end your resume with a brief statement along the lines of "References can be supplied upon request."
·         Resume Checklist
After you've written your resume, and before sending it, go through this checklist:
ร˜  Detail - Make sure you've provided specific examples of your achievements and how you've used the skills you have
ร˜  Tailoring - Make sure everything you've included shows how well-suited you are for the specific job you're applying for
ร˜  Presentation - Make sure the resume is simple and well laid out, printed on clean, white paper in a standard font (e.g., Times, Arial or Verdana) at a standard size (10 or 12 point)
ร˜  Proofreading - Make sure there aren't any spelling mistakes, typos or grammatical errors
ร˜  Get Some Advice - Ask a friend or get a professional to look over your resume before you send it
Conclusion:-  In this way we come to know how to write a good resume.
     Experiment Perform Satisfactorily?                                                    Yes / No
     Assignment submitted timely along with experiment result               Yes / No
     Date on which experiment was performed                 …………………..
Signature of Staff
ASSIGNMENT NO: -7                                                        DATE:-
AIM: - Study write up on Public Speaking.

OBJECTIVE: - Transmiting information to motivate people.

·         THEORY:-
·         Public speaking:

Better Public Speaking Becoming a Confident, Compelling Speaker

Whether we're talking in a team meeting or presenting in front of an audience, we all have to speak in public from time to time.
We can do this well or we can do this badly, and the outcome strongly affects the way that people think about us. This is why public speaking causes so much anxiety and concern.
The good news is that, with thorough preparation and practice, you can overcome your nervousness and perform exceptionally well.

·         The Importance of Public Speaking

Even if you don't need to make regular presentations in front of a group, there are plenty of situations where good public speaking skills can help you advance your career and create opportunities.
For example, you might have to talk about your organization at a conference, make a speech after accepting an award, or teach a class to new recruits. Public speaking also includes online presentations or talks; for instance, when training a virtual team, or when speaking to a group of customers in an online meeting.
Good public speaking skills are important in other areas of your life, as well. You might be asked to make a speech at a friend's wedding, give a eulogy for a loved one, or inspire a group of volunteers at a charity event.
In short, being a good public speaker can enhance your reputation, boost your self-confidence, and open up countless opportunities.
However, while good public speaking skills can open doors, poor speaking skills can close them. For example, your boss might decide against promoting you after sitting through a poorly-delivered presentation. You might lose a valuable new contract by failing to connect with a prospect during a sales pitch. Or you could make a poor impression with your new team, because you trip over your words and don't look people in the eye.
Make sure that you learn how to speak well!

·         Strategies for Becoming a Better Speaker

What's great about public speaking is that it's a learnable skill. As such, you can use the following strategies to become a better speaker and presenter.

ร˜  Plan Appropriately

First, make sure that you plan your communication appropriately. Use tools like the Rhetorical Triangle, Monroe's Motivated Sequence, and the 7Cs of Communication to think about how you'll structure what you're going to say.
When you do this, think about how important a book's first paragraph is; if it doesn't grab you, you're likely going to put it down. The same principle goes for your speech: from the beginning, you need to intrigue your audience.
For example, you could start with an interesting statistic, headline, or fact that pertains to what you're talking about and resonates with your audience. You can also use story telling as a powerful opener; our Expert Interviews with Annette Simmons and Paul Smith offer some useful tips on doing this.
Planning also helps you to think on your feet. This is especially important for unpredictable question and answer sessions or last-minute communications.
ร˜  Tip:
Remember that not all public speaking will be scheduled. You can make good impromptu speeches by having ideas and mini-speeches pre-prepared. It also helps to have a good, thorough understanding of what's going on in your organization and industry.

ร˜  Practice

There's a good reason that we say, "Practice makes perfect!" You simply cannot be a confident, compelling speaker without practice.
To get practice, seek opportunities to speak in front of others. For example, Toastmasters is a club geared specifically towards aspiring speakers, and you can get plenty of practice at Toastmasters sessions. You could also put yourself in situations that require public speaking, such as by cross-training a group from another department, or by volunteering to speak at team meetings.
If you're going to be delivering a presentation or prepared speech, create it as early as possible. The earlier you put it together, the more time you'll have to practice.
Practice it plenty of times alone, using the resources you'll rely on at the event, and, as you practice, tweak your words until they flow smoothly and easily.
Then, if appropriate, do a dummy run in front of a small audience: this will help you calm your jitters and make you feel more comfortable with the material. Your audience can also give you useful feedback, both on your material and on your performance.

ร˜  Engage With Your Audience

When you speak, try to engage your audience. This makes you feel less isolated as a speaker and keeps everyone involved with your message. If appropriate, ask leading questions targeted to individuals or groups, and encourage people to participate and ask questions.
Keep in mind that some words reduce your power as a speaker. For instance, think about how these sentences sound: "I just want to add that I think we can meet these goals" or "I just think this plan is a good one." The words "just" and "I think" limit your authority and conviction. Don't use them.
A similar word is "actually," as in, "Actually, I'd like to add that we were under budget last quarter." When you use "actually," it conveys a sense of submissiveness or even surprise. Instead, say what things are. "We were under budget last quarter" is clear and direct.
Also, pay attention to how you're speaking. If you're nervous, you might talk quickly. This increases the chances that you'll trip over your words, or say something you don't mean. Force yourself to slow down by breathing deeply. Don't be afraid to gather your thoughts; pauses are an important part of conversation, and they make you sound confident, natural, and authentic.
Finally, avoid reading word-for-word from your notes. Instead, make a list of important points on cue cards, or, as you get better at public speaking, try to memorize what you're going to say – you can still refer back to your cue cards when you need them.

ร˜  Pay Attention to Body Language

If you're unaware of it, your body language will give your audience constant, subtle clues about your inner state. If you're nervous, or if you don't believe in what you're saying, the audience can soon know.
Pay attention to your body language: stand up straight, take deep breaths, look people in the eye, and smile. Don't lean on one leg or use gestures that feel unnatural.
Many people prefer to speak behind a podium when giving presentations. While podiums can be useful for holding notes, they put a barrier between you and the audience. They can also become a "crutch," giving you a hiding place from the dozens or hundreds of eyes that are on you.
Instead of standing behind a podium, walk around and use gestures to engage the audience. This movement and energy will also come through in your voice, making it more active and passionate.

ร˜  Think Positively

Positive thinking can make a huge difference to the success of your communication, because it helps you feel more confident.
Fear makes it all too easy to slip into a cycle of negative self-talk, especially right before you speak, while self-sabotaging thoughts such as "I'll never be good at this!" or "I'm going to fall flat on my face!" lower your confidence and increase the chances that you won't achieve what you're truly capable of.
Use affirmations and visualization to raise your confidence. This is especially important right before your speech or presentation. Visualize giving a successful presentation, and imagine how you'll feel once it's over and when you've made a positive difference for others. Use positive affirmations such as "I'm grateful I have the opportunity to help my audience" or "I'm going to do well!"

ร˜  Cope With Nerves

How often have you listened to or watched a speaker who really messed up? Chances are, the answer is "not very often."
When we have to speak in front of others, we can envision terrible things happening. We imagine forgetting every point we want to make, passing out from our nervousness, or doing so horribly that we'll lose our job. But those things almost never come to pass! We build them up in our minds and end up more nervous than we need to be.
Many people cite public speaking as their biggest fear, and a fear of failure is often at the root of this. Public speaking can lead your "fight or flight" response to kick in: adrenaline courses through your bloodstream, your heart rate increases, you sweat, and your breath becomes fast and shallow.
Although these symptoms can be annoying or even debilitating, the Inverted-UModel shows that a certain amount of pressure enhances performance. By changing your mindset, you can use nervous energy to your advantage.
First, make an effort to stop thinking about yourself, your nervousness, and your fear. Instead, focus on your audience: what you're saying is "about them." Remember that you're trying to help or educate them in some way, and your message is more important than your fear. Concentrate on the audience's wants and needs, instead of your own.
If time allows, use deep breathing exercises to slow your heart rate and give your body the oxygen it needs to perform. This is especially important right before you speak. Take deep breaths from your belly, hold each one for several seconds, and let it out slowly.
Crowds are more intimidating than individuals, so think of your speech as a conversation that you're having with one person. Although your audience may be 100 people, focus on one friendly face at a time, and talk to that person as if he or she is the only one in the room.

ร˜  Watch Recordings of Your Speeches

Whenever possible, record your presentations and speeches. You can improve your speaking skills dramatically by watching yourself later, and then working on improving in areas that didn't go well.
As you watch, notice any verbal stalls, such as "um" or "like." Look at your body language: are you swaying, leaning on the podium, or leaning heavily on one leg? Are you looking at the audience? Did you smile? Did you speak clearly at all times?
Pay attention to your gestures. Do they appear natural or forced? Make sure that people can see them, especially if you're standing behind a podium.
Last, look at how you handled interruptions, such as a sneeze or a question that you weren't prepared for. Does your face show surprise, hesitation, or annoyance? If so, practice managing interruptions like these smoothly, so that you're even better next time.
Conclusion:- Thus we conclude that though public speaking we can learn to organize ideas and present them clearly and concisely.
     Experiment Perform Satisfactorily?                                                    Yes / No
     Assignment submitted timely along with experiment result               Yes / No
     Date on which experiment was performed                 …………………..
Signature of Staff
ASSIGNMENT NO: - 8                                                       DATE:-
AIM: - Study write up on Report Writing.
OBJECTIVE: - To help students gain first hand information regarding functioning of the Industry Which presents the students with opportunities to plan, organize and engage in active learning experiences both inside and outside the classroom.
THEORY:-
            Industrial visit is a part of an engineering course, during which students visit companies and get insight regarding the internal working environment of a company and how a company functions, as well as useful information related to the practical aspects of the educational course which cannot be visualized in lectures. The industrial visit is considered one of the most tactical methods of teaching. It provides students with an
opportunity to learn practically through interaction, working methods andemployment practices. Moreover, it gives exposure from an academic point of view.
PURPOSE OF REPORT WRITING:
     The purpose of report writing is to tell some one or specific group of people about the facts that you have studied and give them summary of the fact .
     Structure the report with short paragraphs, graphics such as tables or figures, numbered headings and subheadings, and possibly a bibliography or glossary.
     A narratriting, is a writing which tells a story using many details. Literature and song writers always use this type of writing. This type of writing uses.
      Helps you establish great work and helps you get good grades:
Topic: Report on the industrial visit.
19-Sep-2013
To,
The Principal,
KBT College of Engineering,
Nashik.
Respected Sir,
Sub: Report on the One Day industrial visit
On receiving the letter of permission from Infosys pune, students with two faculty members Prof. Tarle B.S. (HOD Computer Engg.) and Prof.Miss.Tambe U.S. went on an industrial visit to above mentioned S/W industry on 12-09-13. We all assembled at the college at 7 a.m. and started journey by college bus. We reached the industry at 10 a.m. An engineer-in-charge of production received us at the entrance and gave a brief introduction of the industry. Then he took us around one section and explained the process of software development. The employees were doing the work concentrated. He showed how website can be designed, process involved in developing a software, etc. The visit came to an end at 12.00 p.m.
It was an informative, interesting and a successful visit. As students of Computer Engineering, We learned about software development process and about industrial world. We express our thanks to the Principal who permitted us to go on the visit and the faculty members who accompanied us and the employees who explained the various departments. Behalf the students I request you to arrange more industrial visit for students which can practically train the students.
Thanking You!
Yours faithfully,
(Signature)
                                                                                                  Miss. Sathyan Archana.
                                                                            The Class Representative (S.E. Comp)
Conclusion:-  In this way we successfully completed our industrial visit and through this we could learn many upcoming technologies.
     Experiment Perform Satisfactorily?                                                    Yes / No
     Assignment submitted timely along with experiment result               Yes / No
     Date on which experiment was performed                 …………………..
Signature of Staff
ASSIGNMENT NO: -9                                                        DATE:-
AIM: - Study write up on Stress Management.
OBJECTIVE: - To learn practical skills to identify stressors and utilize resources to manage stress.

 

THEORY:-
·         WHAT IS STRESS?
Stress is your mind and body’s response or reaction to a real or imagined threat, event or change. The threat, event or change is commonly called stressors.  Stressors can be internal (thoughts, beliefs, attitudes or external (loss, tragedy, change).
·         LEVELS  OF  STRESS
ร˜  EUSTRESS: Eustress or positive stress occurs when your level of stress is high enough to motivate you to move into action to get things accomplished.
ร˜  DISTRESS: Distress or negative stress occurs when your level of stress is either too high or too low and your body and/or mind begin to respond negatively to the stressors.
·         STAGES OF STRESS
ร˜  ALARM STAGE: As you begin to experience a stressful event or perceive something to be stressful psychological changes occur in your body.  This experience or perception disrupts your body’s normal balance and immediately your body begins to respond to the stressor(s) as effectively as possible.
Example: Cardiac - increased heart rate
ร˜  RESISTANCE STAGE: During this stage your body tries to cope or adapt to the stressors by beginning a process of repairing any damage the stressor has caused.  Your friends, family or co-workers may notice changes in you before you do so it is important to examine their feedback to make sure you do not reach overload.
Example: Behavior indicators include:  lack of enthusiasm for family, school, work or life in general, withdrawal, change in eating habits, insomnia, hypersomnia, anger, fatigue.
ร˜  EXHAUSTION STAGE:   During this stage the stressor is not being managed effectively and the body and mind are not able to repair the damage.
Example: Digestive disorders, withdrawal, headaches, tension, insomnia, loss of temper.
·         How to manage stress:
ร˜  Always take time for yourself, at least 30 minutes per day.
ร˜  Be aware of your own stress meter.
ร˜  Concentrate on controlling your own situation, without controlling everybody else.
ร˜  Daily exercise will burn off the stress chemicals.
ร˜  Eat lots of fresh fruit, vegetables and water.
ร˜  Forgive others, don’t hold grudges and be tolerant not everyone is as capable as you.
ร˜  Gain perspective on things, how important is the issue?
ร˜  Laughter has fun and don’t be afraid to share your feelings with others.
ร˜  Judge your own performance realistically; don’t set goals out of your own reach.
ร˜  Keep a positive attitude, your outlook will influence outcomes and the way others treat you.
ร˜  No is a word you need to use without feeling guilty.
ร˜  Outdoor activates by you, or with friends and family, can be a great way to relax.
ร˜  Play your favorite music rather than watching television.
ร˜  Sleep well.
ร˜  Understand things from the other persons point of view.
ร˜  Yearly goal setting.
ร˜  Zest for life: Each day is a gift, smile and be thankful that you are a part of the bigger picture.
Conclusion:- In this way we analyze how identify stressors and utilize resources to manage stress.

 

     Experiment Perform Satisfactorily?                                                    Yes / No
     Assignment submitted timely along with experiment result               Yes / No
     Date on which experiment was performed                 …………………..
Signature of Staff
ASSIGNMENT NO: -10                                                      DATE:-
AIM: - Team Activity- Use of Language laboratory
OBJECTIVE: - Study & implementation of non-linear data structure such as binary tree
·         Types of traversal
·         Binary tree traversal

 

REQUIRMENTS: - TC
LANGUAGE:-C++
THEORY:-
Write a ‘C++’ program for creation of binary tree and perform recursive and
                   non- recursive traversals -
1) Inorder
2) Preorder
3) Postorder
INPUT:-   A source program in ‘C++’ accepting the number / character for which a binary  tree to be constructed.
OUTPUT (Expected):-
The expected outputs are-
Display all nodes of binary tree in Inorder, Preorder & Postorder form in  
Recursive and Non-recursive format
ALGORITHM :-
Students are expected to write algorithm of the program according to the logic of
1)Creation of Binary tree
2)Recursive Inorder, Preorder & Postorder traversal .
3)Non Recursive Inorder, Preorder & Postorder traversal.
1)      Start
2)      Display the menu
1.      Create tree.
2.      Recursive.
3.      Non Recursive.
4.      Exit
3)      Read the Choice from user
4)      If choice is “1”
a.       Create Root
b.      Create left sub tree if data is less than root.
c.       Create right sub tree if data is greater than root.
5)      If choice is “2” then print menu
a.       Preorder
b.      Inorder
c.       Postorder
d.      Back to main menu
6)      If choice is “3”
a.       Preorder
b.      Inorder
c.       Postorder
d.      Back to main menu
7)      If choice is “4”
1.      Exit the program .
8)      Stop.
Program:
/*   Create binary tree and perform recursive and  non-recursive traversal
*/

#include<conio.h>
#include<iostream.h>
#include<stdlib.h>

class node
{
  public:
        int data;
        node *left,*right;
        node(int x)
          {
                data=x;
                left=right=NULL;
          }
};

class tree
 {
        node *root;
        void inorder1(node *T);//recursive counterpart of inorder()
        void preorder1(node *T);//recursive counterpart of preorder()
        void postorder1(node *T);//recursive counterpart of postorder()
        node *create1();//Recursive counterpart of create
    public:
        tree() { root=NULL;}
        void create() { root=create1();}
        void inorder(){inorder1(root);}
        void preorder(){preorder1(root);}
        void postorder(){postorder1(root);}
        void non_rec_inorder();
        void non_rec_preorder();
        void non_rec_postorder();

 };

class stack
  {
        node *data[30];
        int top;
        public:
                stack(){top=-1;}
                int empty()
                   {
                        if(top==-1)
                                return 1;
                        return 0;
                   }
        void push(node *p)
                   {
                        data[++top]=p;
                   }
        node *pop()
           {
                   return(data[top--]);
           }
 };

void tree::inorder1(node *T)
 {
        if(T!=NULL)
        {
                inorder1(T->left);
                cout<<"  "<<T->data;
                inorder1(T->right);
        }
  }

void tree::preorder1(node *T)
{       if(T!=NULL)
          {
                cout<<"  "<<T->data;
                preorder1(T->left);
                preorder1(T->right);
          }
 }

void tree::postorder1(node *T)
 {
        if(T!=NULL)
           {
                postorder1(T->left);
                postorder1(T->right);
                cout<<"  "<<T->data;
           }
 }


 node * tree::create1()
  {
        node *p;
        int x;
        cout<<"\n Enter a data(-1 for no data or Null node ) : ";
        cin >> x;
        if(x==-1)
             return NULL;
        p=new node(x);
        cout<<"\nEnter left child of "<<x ;
        p->left=create1();
        cout<<"\nEnter right child of "<<x;
        p->right=create1();
        return p;
  }


void tree::non_rec_inorder()
   {
        stack s;
        node *T=root;
        cout<<"\n";
        while(T!=NULL)
           {
                s.push(T);
                T=T->left;
           }
        while(!s.empty())
           {
                T=s.pop();
                cout <<"  "<<T->data;
                T=T->right;
                while(T!=NULL)
                   {
                        s.push(T);
                        T=T->left;
                   }
           }
  }


void tree::non_rec_preorder()
   {
        stack s;
        node *T=root;
        cout<<"\n";
        while(T!=NULL)
           {
                cout <<"  "<<T->data;
                s.push(T);
                T=T->left;
           }
        while(!s.empty())
           {
                T=s.pop();
                T=T->right;
                while(T!=NULL)
                    {
                        cout <<"  "<<T->data;
                        s.push(T);
                        T=T->left;
                    }
           }
  }

void tree::non_rec_postorder()
   {
        stack s,s1;     /*stack s1 is being used for flag . A NULL data
                        implies that the right subtree has not been visited */
        node *T=root;
        cout<<"\n";
        while(T!=NULL)
           {
                s.push(T);s1.push(NULL);
                T=T->left;
           }
        while(!s.empty())
           {
                T=s.pop();
                if(s1.pop() == NULL)
                    {
                        s.push(T);s1.push((node*)1);//flag =1
                        T=T->right;
                        while(T!=NULL)
                           {
                                s.push(T);s1.push(NULL);
                                T=T->left;
                           }
                    }
                else
                        cout<<"  "<<T->data;
           }
  }


void main()
{
        tree  t1;
        node *p;
        int x,op;
        clrscr();
        do
           {
                cout<<"\n\n1)Create\n2)Preorder(recursive)";
                cout<<"\n3)Inorder(recursive)\n4)Postorder(Recursive)";
                cout<<"\n5)Inorder(Non-Recursive)";
                cout<<"\n6)Preorder(Non-REcursive)";
                cout<<"\n7)Postorder(Non-REcursive)\n8)Quit";
                cout <<"\nEnter Your Choice :";
                cin>>op;
                switch(op)
                   {
                        case 1: t1.create();break;
                        case 2: t1.preorder();break;
                        case 3: t1.inorder();break;
                        case 4: t1.postorder();break;
                        case 5: t1.non_rec_inorder();break;
                        case 6: t1.non_rec_preorder();break;
                        case 7: t1.non_rec_postorder();break;
                    }
           }while(op!=8);

}

Conclusion:- Thus, we perform different operations on tree.
     Experiment Perform Satisfactorily?                                                    Yes / No
     Assignment submitted timely along with experiment result               Yes / No
     Date on which experiment was performed                 …………………..
Signature of Staff

No comments :

Post a Comment