Friday 15 August 2014

Is this Pattern of English Grammer is Correct...???

I NEED YOUR SUGGESTION...!!!
Hi friend's I am trying to do some pattern recognition kind of work in English Grammer.

In pattern recognition of ENGLISH language few things are so important and other are important too but with less weightage.
See below image:
"I HAVE TRIED TO GIVE THE WORLD SHORTEST DEFINITION OF PARTS OF SPEECH."


Here NOUN, VERB, ADJECTIVE & ADVERB are more important rather than INTERJECTION, where as interjection is little more important than PRONOUN, PREPOSITION and CONJUCTION










In english grammer,

  • Mostly sentences are start with NOUN followed by VERB
  • NOUN is qualified by adjective
  • VERB & ADJECTIVE is qualified by ADVERB.
  • CONJUCTION is use to join two sentences.
So, On this basis I have developed some pattern.
See below image:
Sentences start with Noun followed by Verb, which further can be qualified by adjective and adverbs. In the paragraph writting we always use pronouns in place of nouns. And the last thing is that to join the words we use proposition and to join sentences we use conjuction.

Wednesday 26 October 2011

implementation of a program to count the no. of leaves in a tree

//program is implemented by shadab khan
#include <stdio.h>
#include <stdlib.h>

/* A binary tree node has data, pointer to left child
and a pointer to right child */
struct node
{
int data;
struct node* left;
struct node* right;
};

/* Function to get the count of leaf nodes in a binary tree*/
unsigned int getLeafCount(struct node* node)
{
if(node == NULL)
return 0;
if(node->left == NULL && node->right==NULL)
return 1;
else
return getLeafCount(node->left)+
getLeafCount(node->right);
}

/* Helper function that allocates a new node with the
given data and NULL left and right pointers. */
struct node* newNode(int data)
{
struct node* node = (struct node*)
malloc(sizeof(struct node));
node->data = data;
node->left = NULL;
node->right = NULL;

return(node);
}

/*Driver program to test above functions*/
int main()
{
/*create a tree*/
struct node *root = newNode(1);
root->left        = newNode(2);
root->right       = newNode(3);
root->left->left  = newNode(4);
root->left->right = newNode(5);

/*get leaf count of the above created tree*/
printf("Leaf count of the tree is %d", getLeafCount(root));

getchar();
return 0;
}

implementation of stack

//program is implemented by shadab khan
#include<conio.h>
#include<iostream.h>
#include<process.h>

void main()
{
            int stack[150],top,n,i,max_stack,choice,element,n_pop;
            max_stack=150;
            cout<<"How many elements are in the stack: ";
            cin>>n;
            cout<<"Enter "<<" elements.\n";
            for(top=0;top>stack[top];top++)
            {
                        cin>>stack[top];
            }
            cout<<"\nStack is implemented.\nThe stack is\n";
            for(i=top-1;i>=0;i--)
                        cout<<"   ";
            getch();
            while(1)
            {
                        clrscr();
                        cout<<"1: PUSH\n2: POP\n3: Display Stack\n4: Exit\nEnter your choice: ";
                        cin>>choice;
                        switch(choice)
                        {
                                    case 1:     //  PUSH
                                                cout<<"\nPUSH OPERATION\n";
                                                if(top>=max_stack)
                {
                                                            cout<<"Stack is full!";
                                                            getch();
                                                            break;
                                                }
                                                cout<<"Enter an element: ";
                                                cin>>element;
                                                stack[top]=element;
                top++;
                                                cout<<"Item Inserted!";
                                                getch();
                                                break;
                                    case 2:             // POP
                                                cout<<"POP OPERATION\n";
                                                if(top<0)
                                                {
                                                            cout<<"Stack is empty";
                                                            getch();
                                                            break;
                                                }
                                                cout<<"How many elements you want to pop: ";
                cin>>n_pop;
                                                if(n_pop>top)
                                                {
                                                            cout<<"\nError!\nStack is small.";
                                                            getch();
                   break;
                                                }
                                                top=top-n_pop;
                                                cout<<"Items POPed";
                                                getch();
                                                break;
                                    case 3:       //  Display
                                                cout<<"\The stack is\n";
                                                for(i=top-1;i>=0;i--)
                                                            cout<< stack[i] <<"   ";
                                                getch();
                                                break;
                                    case 4:
                                                exit(0);
                                                getch();
                                    default:
                                                cout<<"RE-enter your choice!";
                        }          // End of switch
            }                      // End of while
            getch();
}

implementation of merging of two array or list

/*
ALGORITHM:

1. Initialized low1=0 of A array and low2=0 of B array.
2. Repeat step 2 until low1<n && low2<n.
            a. copy element of A array into C array if element of A array is smaller than B.
            b. Other wise copy element of B array into C array.
3. Repeat if any element of A array is still left to be insert into C array i.e. low1<n
4. Repeat if any element of B array is still left to be insert into C array i.e. low2<n
*/
//program is implemented by shadab khan
#include<iostream.h>
#include<conio.h>
void main()
{
            clrscr();
            int a[5],b[5],c[10],i,j,k;
            cout<<"enter the 5 element of Ist array : \n\n";
            for(i=0;i<=4;i++)
            cin>>a[i];
            cout<<"enter the 5 element of IInd array : \n\n";
            for(i=0;i<=4;i++)
            cin>>b[i];
            i=0;j=0;k=0;
            while(i<5 && j<5)
            {
                        if(a[i]<b[j])
                        {
                                    c[k]=a[i];
                                    i++;
                                    k++;
                        }
                        else
                        {
                                    c[k]=b[j];
                                    j++;
                                    k++;
                        }
            }
            while(i<5)
            {
                        c[k]=a[i];
                        i++;
                        k++;
            }
            while(j<5)
            {
                        c[k]=b[j];
                        j++;
                        k++;
            }
            cout<<"Merged array : \n\n";
            for(i=0;i<=9;i++)
            cout<<c[i]<<endl;
            getch();
            }

implementation of insertion sort

//program is implemented by shadab khan
#include<iostream.h>
#include<conio.h>
void main()
{
            clrscr();
            int a[5], i,t,p;
            cout<<”enter the 4 element of array”;
            for(i=1;i<=4;i++)
            cin>>a[0];
            a[0]=NULL;
            for(i=2;i<=4;i++)
            {
                        t=a[i];
                        p=i-1;
                        while(t<a[p])
                        {
                        a[p+1]=a[p];
                        P=p-1;
                        }
            a[p+1]=t;
            }
            cout<<”Elements after insertion sort : \n\n”;
            for(i=0;i<=4;i++)
            {
                        cout<<a[i]<<endl;
            }
            getch();
}

implementation of selection sort algorithm

//program is implemented by shadab khan
#include<iostream.h>
#include<conio.h>
void main()
{
            clrscr();
            int a[5], i,j,t,p,s;
            cout<<”enter the 5 element of array”;
            for(i=0;i<=4;i++)
            cin>>a[0];
            for(i=0;i<=4;i++)
            {
                        s=a[i];
                        p=I;
                        for(j=i=1;j<=4;j++)
                        {
                                    if(s>a[j])
                                    {
                                                s=a[j];
                                                p=j;
                                    }
                        }
                        t=a[i];
                        a[i]=a[p];
                        a[p]=t;
            }
            cout<<”5 sorted elements of array”;
            for(i=0;i<=4;i++)
            cout<<a[i];
            getch();
}

implementation of bubble sort

//program is implemented by shadab khan
#include<iostream.h>
#include<conio.h>
void main()
{
            clrscr();
            int a[5], i,j,t;
            cout<<”enter the 5 element of array”;
            for(i=0;i<=4;i++)
            cin>>a[0];
            for(i=0;i<=4;i++)
            {
                        for(j=0;j<=4-I;j++)
            {
                        if(a[j]>a[j+1])
                        {
                                    t=a[j];
                                    a[j]=a[j+1];
                                    a[j+1]=t;
                        }
            }
            }
            cout<<”5 sorted elements of array”;
            for(i=0;i<=4;i++)
            cout<<a[i];
            getch();
}