Labels

Saturday, June 1, 2013

Cheated by Naukri.com

My experience with Naukri.com  :

After 6 months in my first job I learned some new skills and I thought I should update them on linkedin or Naukri.com, not because I was looking to change my job just because I fuc***g acquired some new skills.

After a few days of my update my manager calls me to his office and asks me why do I want to change job? I was shocked at first I did not understand why he was saying that. I just assured him that I was very much satisfied with my job and have no reason to look for another,which was 100% truth at that point of time .

Thinking about the incident later it became very clear that the only reason for him to think that I am looking for a change is my naukri profile.

Later when I talked with some of my senior colleagues things became crystal clear. HR of my company takes employee attrition very seriously and they have premium consultant accounts at all major job search websites and continuously monitor employee activities. 

This can happen to you too, so do not post anything on these fu****g sites unless you are very sure of leaving the company.

Anyways these site are pretty much useless and only shows useless job openings.

Saturday, May 18, 2013

Quick sort c++ code

#include<iostream.h>
#include<conio.h>
int count=0;
int partition(int a[],int  p,int r)
{

    int x,j;
    x=a[r];
    int i=p-1;
    for(j=p;j<r-1;j++)
    {
        if(a[j]<=x)
        {
            i=i+1;
            int t=a[i];
            a[i]=a[j];
            a[j]=t;
        }
    }
    int g=a[i+1];
    a[i+1]=a[r];
    a[r]=g;
    return(i+1);
}


int quicksort( int A[],int p,int r)
{
    int q;
    if(p<r)
    {
        q=partition(A,p,r);
        quicksort(A,p,q-1);
        quicksort(A,q+1,r);
    }
}

void main()
{
    int a[20],n;
    cout<<"Enter the size of the array: "  ;
    cin>>n;
    cout<<"ENTER ARRAY ELEMENTS: \n";
    for(int i=0; i<n; i++)
        cin>>a[i];
    quicksort(a,0,n-1);
    cout<<"YOUR SORTED ARRAY IS: \n";
    for(int i=0;i<n;i++)
        cout<<a[i]<<endl;
    getch();
}

Bucket sort C++ code

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

class node
{
    public:
        float info;
        node *next,*prev;
        node(){next=prev=0;}
        node(int n, node *ptr=0, node *ptr1=0)
        {
            info=n;
            next=ptr;
            prev=ptr1;
        }
};

/* sort the link list of elements*/
void isort(node *head)
{
    if (head == 0)
        return;
    float key;
    node *j,*i, *q=0;

    for(i=head->next;i!=0;i=i->next)
    {
        q=0;
        key = i->info;
        j=i->prev;
        while(j!=0 && key < (j->info) )
        {
            j->next->info=j->info;
            q = j;
            j=j->prev;
        }

        if(q!=0)
            q->info = key;
    }

}


void bucket_sort(float *a,int n)
{
    /* create buckets */
    node* *b = new node* [n];
    for(int i=0; i<n;i++)
        b[i]=0;

    /* step 2 begins - insert a[i] into buckets */
    for(int i=0;i<n;i++)
    {
        int index=n*a[i];

        node *temp=new node(sizeof(node));
        temp->info=a[i];

        if(b[index]==NULL)
        {
            b[index]=temp;
        }
        else
        {
            temp->next=b[index];
            b[index]->prev=temp;
            b[index]=temp;
        }
    } // end of for
    /* step 2 ends */

    /* step 3 begins - sort each bucket */
    for(int i=0; i<n;i++)
    {
        isort(b[i]);
    }
    /* step 3 ends */

    /* step 4 begins - concatenate all the buckets */
    node *trav=0;
    cout<<"\n\nSorted array is: \n";
    for(int i=0; i<n;i++)
    {
        trav = b[i];
        while(trav != 0)
        {
            cout<<trav->info<<" ";
            trav = trav->next;
        }
    }
    /* step 4 ends */
}

void main()
{
    clrscr();

    int n;
    float *a;

    cout<<"\n\t Enter the size of array  :  ";
    cin>>n;

    cout<<"\n\t Enter the elements of an array  :\n";
    a=new float[n];
    for(int l=0;l<n;l++)
        cin>>a[l];

    cout<<"\n\t Unsorted array is..\n";
    for(l=0;l<n;l++)
        cout<<a[l]<<" ";
    cout<<"\n" ;

    /* sort lements using buckt sort */
    bucket_sort(a,n);

    getch();
}

Radix sort c++ code

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

void countingsort(char s[][20],int a[],char b[][20],int n,int k)
{   int c[100];
    int l,j,i;
    for( l=0;l<=k;l++)
        c[l]=0;
    for(j=0;j<n;j++)
        c[a[j]]=c[a[j]]+1;
    for(i=1;i<=k;i++)
        c[i]=c[i]+c[i-1];
    for(j=n-1;j>=0;j--)
    {
        strcpy(b[c[a[j]]-1],s[j]);
        c[a[j]]=c[a[j]]-1;
    }
    for(i=0;i<n;i++)
    {
        strcpy(s[i],b[i]);
    }
}

void radixsort(char s[][20],int d,int n)
{  int z[20];
    char b[20][20];
    int i,j,k;
    j=d-1;
    for(i=1;i<=d;i++)
    {
        for(k=0;k<n;k++)
        {
            z[k]=s[k][j]-48;
        }
        --j;

        countingsort(s,z,b,n,9);
    }
    cout<<"Output"<<endl;
    for(i=0;i<n;i++)
        cout<<b[i]<<endl;
}


void main()
{
    int n,i,d;
    char a[20][20];
    cout<<"Entr the size of the array"<<endl;
    cin>>n;
    cout<<"Enter the no. of digits"<<endl;
    cin>>d;
    cout<<"Enter its element"<<endl;
    for(i=0;i<n;i++)
        cin>>a[i];
    radixsort(a,d,n);

    getch();
}

priority queue c++ code

#include<iostream.h>
#include<conio.h>
#include<process.h>
int n;
void maxheapinsert(int [],int key);
void heapincreasekey(int a[],int i,int key);
int heapextractmax(int a[]);
int prioritymaximum(int a[]);
void max_heapify(int a[20],int n1);
int heapsize;
int left(int i)
{
    return(2*i);
}
int right(int i)
{
    return((2*i)+1);
}
void max_heapify(int A[20],int i)
{
    int l,r,largest,s;
    l=left(i);
    r=right(i);

    if(l<=heapsize && A[l]>A[i])
        largest=l;
    else
        largest=i;

    if(r<=heapsize && A[r]>A[largest])
        largest=r;

    if(largest!=i)
    {
        s=A[i];
        A[i]=A[largest];
        A[largest]=s;
        max_heapify(A,largest);
    }
}
int prioritymaximum(int a[])
{

    return a[1];
}
int heapextractmax(int a[])
{
    if(n<0)
        cout<<"Underflow"<<endl;
    int max=a[1];
    a[1]=a[n];
    n--;
    max_heapify(a,1);
    return max;
}

void heapincreasekey(int a[],int i,int k)
{
    if(k<a[i])
        cout<<"New key is smaller than current key"<<endl;
    a[i]=k;
    while(i>1&&a[i/2]<a[i])
    {
        int t=a[i];
        a[i]=a[i/2];
        a[i/2]=t;
        i=i/2;
    }
}
void maxheapinsert(int a[],int k)
{
    n=n+1;
    a[n]=-999;
    heapincreasekey(a,n,k);
}

void main()
{
    int x,i2,c,key,a[20];
    a[0]=-999;
    int m;
    for(  ;  ; )
    {
        cout<<"Menu:"<<endl;
        cout<<"1:To get the maximum value"<<endl;
        cout<<"2:To extract maximum value"<<endl;
        cout<<"3:To increase key value"<<endl;
        cout<<"4:To insert new value"<<endl;
        cout<<"5:Exit:"<<endl;
        cout<<"Enter your choice"<<endl;
        cin>>c;
        switch(c)
        {
            case 1:
                x=prioritymaximum(a);
                cout<<x<<endl;
                break;
            case 2:
                m=heapextractmax(a);cout<<"process with priority "<<m<<" is being processed";
                break;
            case 3:
                cout<<"Enter the index value that is to modified "<<endl;
                cin>>i2;
                cout<<"Enter the new value"<<endl;
                cin>>key;
                heapincreasekey(a,i2,key);
                cout<<"Value modified"<<endl;
                break;
            case 4:
                cout<<"Enter the new value"<<endl;
                cin>>key;
                maxheapinsert(a,key);
                break;
            case 5:
                exit(0);
            default:
                cout<<"Wrong code"<<endl;
        }
    }
    getch();
}

Merge sort C++ code

#include<iostream.h>
#include<conio.h>
void merge(int a[], int p, int q, int r)
{
    int i,j;
    int n1, n2;
    n1=q-p+1;
    n2=r-q;
    int L[21], R[21];
    for(int i=0; i<n1; i++)
        L[i]=a[p+i];
    for(int j=0; j<n2; j++)
        R[j]=a[q+j+1];
    L[n1]=999;
    R[n2]=999;
    i=0; j=0;
    for(int k=p; k<=r; k++)
    {
        if(L[i]<=R[j])
        {
            a[k]=L[i];
            i++;
        }

        else
        {
            a[k]=R[j];
            j++;
        }
    }
}
void merge_sort(int a[], int p,int r)
{
    int q;
    if(p<r)
    {
        q=(p+r)/2;
        merge_sort(a, p, q);
        merge_sort(a, q+1, r);
        merge(a, p, q, r);
    }
}

void main()
{
    int a[20],n;
    cout<<"Enter the size of the array: "  ;
    cin>>n;
    cout<<"ENTER ARRAY ELEMENTS: \n";
    for(int i=0; i<n; i++)
        cin>>a[i];
    merge_sort(a,0,n-1);
    cout<<"YOUR SORTED ARRAY IS: \n";
    for(int i=0;i<n;i++)
        cout<<a[i]<<endl;
    getch();}



Insertion sort C++ code

#include<iostream.h>
#include<conio.h>
void insertion_sort(int a[10],int n)
{
int j,key,i;
for( j=1;j<n;j++)
{
 key=a[j];
 i=j-1;
 while(i>=0&&a[i]>key)
   {
     a[i+1]=a[i];
       i=i-1;
   }
   a[i+1]=key;
}
}
void main()
{

 int a[20],n;

 cout<<"enter the size of array\n";
 cin>>n;
 cout<<"enter the elements\n";
 for(int i=0;i<n;i++)
  cin>>a[i];

  insertion_sort(a,n);

 cout<<"sorted array is\n";
  for(int i=0;i<n;i++)
    cout<<a[i]<<",";
   getch();
 }