Thursday, January 15, 2015

How to implemet Linear Queue By Linklist?

#include<iostream>
#include<stdlib.h>
using namespace std;
struct node
{
                int data;
                struct node *next;
}*front=NULL,*rear,*temp;
void ins()
{
                temp=new node;
                cout<<"Enter data:";
                cin>>temp->data;
                temp->next=NULL;       

                if(front==NULL)
                                front=rear=temp;
                else
                {
                                rear->next=temp;
                                rear=temp;
                }
                cout<<"Node has been inserted\n";     
}
void del()
{
                if(front==NULL)
                                cout<<"Queue is empty\n";
                else
                {
                                temp=front;
                                front=front->next;
                                cout<<"Deleted node is "<<temp->data<<"\n";
                                delete(temp);
                }
}
void dis()
{
                if(front==NULL)
                                cout<<"Queue is empty\n";
                else
                {
                                temp=front;
                                while(temp->next!=NULL)
                                {
                                                cout<<temp->data<<"->";
                                                temp=temp->next;
                                }

                                cout<<temp->data;
                }
}
main()
{
                int ch;
                while(1)
                {
                                cout<<"\n*** Menu ***"<<"\n1.Insert\n2.Delete\n3.Display\n4.Exit";
                                cout<<"\n\nEnter your choice(1-4):";
                                cin>>ch;
                                cout<<"\n";

                                switch(ch)
                                {
                                                case 1:  ins();
                                                                break;
                                                case 2: del();
                                                                break;
                                                case 3: dis();
                                                                break;
                                                case 4: exit(0);
                                                                break;
                                                default: cout<<"Wrong Choice!!!";
                                }
                }

                return 0;
}

How to create,insert,delete and reverse Linear Doubly linklist in C++?

//Lab 7 Solution
#include<iostream>
#include<conio.h>
#include<malloc.h>
#include<process.h>
using namespace std;
void create_list();
void display();
void addatbeg( );
void addafter(int);
void del(int);
void rev();
struct node{
       int data;
       struct node *next;
       struct node *prev;
}* start;

int main(){

int choice,n,position,i;
int a;
int b;
start=NULL;
while(1)
{
cout<<"1. Create List"<<endl;
cout<<"2. Display List"<<endl;
cout<<"3. Add at Begining"<<endl;
cout<<"4. Add in middle"<<endl;
cout<<"5. Deletion"<<endl;
cout<<"6. Reverse"<<endl;
cout<<"7. Quit Program"<<endl;


cin>>choice;
switch(choice)
{
case 1:
cout<<"How many Nodes you Want? "<<endl;
cin>>n;
for (i=1;i<=n;i++)
{

create_list();
}
break;
case 2:
display();
break;
case 3:
    

addatbeg();
break;
case 7:
exit(0);
case 4:
    

cout<<"Enter position";
cin>>position;
addafter(position);
break;
case 5:
     int m;
     cout<<"enter Element to be deleted"<<endl;
     cin>>m;
     del(m);
     break;
     case 6:
          rev();
          display();
          break;
     default:
cout<<"Wrong Choice"<<endl;
}
}
getch();
return 0;
}
void create_list()
{
struct node *q,*tmp;
tmp=(node*)malloc(sizeof(struct node));
cout<<"Enter data"<<endl;
cin>>tmp->data;
tmp->next=NULL;
tmp->prev=NULL;
if(start==NULL)
{
tmp->prev=NULL;
start=tmp;
}
else
{
q=start;
while(q->next!=NULL)
q=q->next;
q->next=tmp;
tmp->prev=q;
}
}
void display()
{
struct node *q;
if(start==NULL)
{
cout<<"Empty List"<<endl;
return;
}
else
{
q=start;
while(q!=NULL)
{
cout<<q->data<<"\t";
q=q->next;
}
}
cout<<"\n";
}
void addatbeg()
{
struct node *tmp;
tmp=(node *)malloc(sizeof(struct node));

cout<<"enter data"<<endl;
cin>>tmp->data;
tmp->prev=NULL;
tmp->next=start;
start->prev=tmp;
start=tmp;
}
void addafter(int pos)
{
struct node *tmp, *q;
tmp=(node *)malloc(sizeof(struct node));
int i;
q=start;
for(i=1;i<pos-1;i++)
{
q=q->next;
if(q==NULL)
{
cout<<"There are less elements"<<pos;
return;
}
}
tmp=(node *)malloc(sizeof(struct node));
cout<<"Enter data"<<endl;
cin>>tmp->data;
q->prev=tmp;
tmp->next=q->next;
tmp->prev=q;
q->next=tmp;
}

void del(int data)
{
     struct node *q,*tmp;
     if(start->data==data)
     {
                          tmp=start;
                          start=start->next;
                          start->prev=NULL;
                          free(tmp);
                          return;
                          }
                          q=start;
                          while(q->next!=NULL)
                          {
                                                    if(q->data==data)
                                                    {
                                                                            tmp=q->next;
                                                    q->next=tmp->next;
                                                    tmp->next->prev=q;
                                                    free(tmp);
                                                    return;
                                                    }
                                                    q=q->next;
                                                    }
                                                    if(q->data==data)
                                                    {
                                                                           tmp=q->next;
                                                                          
                                                                           q->next=NULL;
                                                                           free(tmp);
                                                                            return;
                                                                           }
}
void rev()
{
     struct node *p1,*p2;
     p1=start;
     p2=p1->next;
     p1->next=NULL;
     p1->prev=p2;
     while(p2!=NULL)
     {
                    p2->prev=p2->next;
                    p2->next=p1;
                    p1=p2;
                    p2=p2->prev;
                    }
                    start=p1;
}
              
                                                                               

How to create,insert,delete and reverse Doubly Circular linklist in C++?

#include<iostream>
#include<conio.h>
using namespace std;
 struct circular
{
    int i;
    struct circular *front;
    struct circular *back;
};
struct circular *temp;
struct circular *head;
struct circular *p;
struct circular *mid;
struct circular *move;

int cnt=0;


void create(void);
void insert(void);
void display(void);
void del(void);



//Creating a node
void create()
{

   
    head=(struct circular *)malloc(sizeof(struct circular));
    head->back=head;
    head->front=head;

    cout<<"ENETER THE DATA\n";
    cin>>head->i;
    temp=head;

    temp->back=(struct circular *)malloc(sizeof(struct circular));
    temp=temp->back;
    temp->back=head;
    head->front=temp;
cout<<"ENETER THE DATA\n";
    cin>>temp->i;


   
}

//Displaying the list
void display()
{
    p=head;
    cout<<p->i;
    p=p->back;
    while(p!=head)
    {
        cout<<p->i;
        p=p->back;
    }
    cout<<"\n";

}

//Inserting a new node
void insert()
{
    int add,t;

    cout<<"\n\t ENTER ANY NUMBER BETWEEN 1 AND %d\n"<<cnt;
    cin>>add;
    p=head;
    t=1;
    while(t<add)
    {
        p=p->back;
        t++;
    }
    mid=(struct circular *)malloc(sizeof(struct circular));
    cout<<"\n\n\nENETER THE DATA\n";
    cin>>mid->i;

    mid->back=p->back;
    p->back=mid;
    p->back->front=mid;
    mid->front=p;

}

//Deleting a node
void del(void)
{
    int add,t;

    cout<<"\n\n\t ENTER ANY NUMBER BETWEEN 1 AND %d\n"<<cnt;
    cin>>add;
    p=head;
    t=1;
    while(t<add-1)
    {
        p=p->back;
        t++;
    }
  
    mid=p->back;
    p->back=mid->back;
    mid->back->front=p;
    free(mid);
}


//Calling in main()
int main()
{
    int ch=0;
    while(ch!=5)
    {
        cout<<"\n1.CREATE";
        cout<<"\n2.INSERT";
        cout<<"\n3.DELETE";
        cout<<"\n4.DISPLAY";
        cout<<"\n5.EXIT\n";
        cin>>ch;


        if(ch==1)
        {
            create();
            cnt++;
            cnt++;
        }

        if(ch==2)
        {
            insert();
            cnt++;
        }
        if(ch==3)
        {
            del();
            cnt--;
        }

        if(ch==4)
        {
            display();
        }

        if(ch==5)
        {
            break;
        }
    }
}

How to create,insert,delete and reverse Signly Circular linklist in C++?

//Implementation of Circular List
#include<conio.h>
#include<iostream>
#include<malloc.h>
using namespace std;
void creation();
void traversing();
void addatbeg();
void addafter(int, int);
void deletion(int);
struct node{
    int info;
    node *link;
   
}*last;
int n;
int main()
{
    last = NULL;
    int ch;
    while(1)
    {
        cout<<"1.Creation";
        cout<<endl;
        cout<<"2.Traversing";
        cout<<endl;
        cout<<"3.Insertion at start";
        cout<<endl;
        cout<<"4. Insertion any Where"<<endl;
        cout<<"5.Deletion";
        cout<<endl;
        cout<<"6.exit";
        //cout<<endl;
        cout<<"Enter Your Choice";
        cin>>ch;
   
    switch(ch)
    {
        case 1:
            int n;
            cout<<"enter number of nodes";
            cin>>n;
            for(int i=0;i<n;i++)
            creation();
            break;
            case 2:
                traversing();
                break;
                case 3:
                    
                    addatbeg();
                    break;
                    case 4:
                         int i;
                         cout<<"enter Position"<<endl;
                         cin>>i;
                         int data;
                         cout<<"Enter Data"<<endl;
                         cin>>data;
                        addafter(data,i);
                        break;
                        case 5:
                             int m;
                             cout<<"Enter data to be deleted"<<endl;
                            cin>>m;
                            deletion(m);
                            break;
                        case 6:
                             exit(0);
      default:
                            cout<<"Sorry!Wrong Choice :(";
                            cout<<endl;
                           
    }}
    getch();
    return(0);
}
void creation()
{
    struct node *temp;
    temp=(node*)malloc(sizeof(struct node));
    int data;
    cout<<"Enter Data ";
    cin>>data;
    temp->info=data;
    cout<<endl;
    if(last==NULL)
    {
        last=temp;
        last->link=last;
    }
    else
    {
        temp->link=last->link;
        last->link=temp;
        last=temp;
    }
}
void traversing()
{
    struct node *q;
    q=last->link;
    while(q!=last)
    {
        cout<<"data is "<<q->info;
        cout<<endl;
        q=q->link;
    }
    cout<<last->info;
    cout<<endl;
}
void addatbeg()
{
        int Data,k;
    struct node *tmp,*q;
    tmp=(node*)malloc(sizeof(struct node));
    cout<<"Enter Data";
    cin>>Data;
    cout<<endl;
    tmp->info=Data;
    tmp->link=last->link;
    last->link=tmp;
}
void addafter(int data, int pos)
{
     struct node *q,*tmp;
     int i;
     q=last->link;
     for(i=0;i<pos-1;i++)
     {
                         q=q->link;
                         if(q==last->link)
                         {
                                          cout<<"Less Elements "<<endl;
                                          return;
                         }
     }
                        
     tmp=(node*)malloc(sizeof(struct node));
     tmp->info=data;
     tmp->link=q->link;
     q->link=tmp;
     if(q==last)
     {
                last=tmp;
     }
}
void deletion(int data)
{
//    int chh,m,data;
        struct node *tmp,*q;
       
    if(last->link==last&&last->info==data)
            {
            tmp=last;
            last=NULL;
            free(tmp);
            return;
       
            }
           
                    q=last->link;
                    if(q->info==data)
                    {
                        tmp=q;
                        last->link=q->link;
                        free(tmp);
                        return;
                    }
                    while(q->link!=last)
                            {
                                if(q->link->info==data)
                                {
                                    tmp=q->link;
                                    q->link=tmp->link;
                                free(tmp);
                                return;
                            }
                                q=q->link;
   
                        }
                if(q->link->info==data)
                {
                    tmp=q->link;
                    q->link=last->link;
                    free(tmp);
                    last=q;
                    return;
                }
}

How to create,insert,delete and reverse signly linear linklist in C++?

The program which I am posting here you will not find any where on internet. It is very easy to understand. I have attached some pics. SO that you can learn the algorithm of this program as well.
#include<iostream>
#include<conio.h>
#include<malloc.h>
using namespace std;
void creat(int m);
void display();
void rev();
void insert(int data,int pos);
void del(int data1);
struct node
  {
     int info;
     struct node *link;
  }*start;
int main ()
{

    start =NULL;
    int ch,n,m,data,pos;
    while(1)
    {
            cout<<"1. Create List"<<endl;
            cout<<"2. Display List"<<endl;
            cout<<"3. Insertion"<<endl;
            cout<<"4. Deletion"<<endl;
            cout<<"5. Reverse"<<endl;
            cout<<"6. Exit"<<endl;
            cin>>ch;
            switch(ch)
            {
                      case 1:
                           cout<<"\nenter num of nodes to create:: ";
                           cin>>n;
                           for(int i=0;i<n;i++)
                           {
                                   cout<<"\nenter data::";
                                   cin>>m;
                                   creat(m);
                                   }
                                   break;
                                   case 2:
                                        display();
                                        break;
                                        case 3:
                                                  cout<<"\nenter data";
                                                  cin>>data;
                                                  cout<<"\nenter position";
                                                  cin>>pos;
                                                  insert(data,pos);
                                                  display();
                                                  break;
                                                  case 4:
                                                          int data1;
                                                            cout<<"\nenter data, u want to del node ";
                                                             cin>>data1;
                                                             del(data1);
                                                             display();
                                                             break;
                                        case 5:
                                             cout<<"\nafter reverse\n";
                                             rev();
                                             display();
                                             break;
                                                                     
                                                             case 6:
                                                                  exit(0);
                                                                 
                                                             default:
                                                                     cout<<"invalid choice";
                                                                     }
                                                                     }
    
     return 0;
}
void creat(int m)
  {
    struct node *temp,*q;
    temp=(node*)malloc(sizeof(node));
    temp->info=m;
    temp->link=NULL;
    if(start==NULL)
     {
     start=temp;
     }

    else
     {
     q=start;
     while(q->link!=NULL)
   
        q=q->link;


      q->link=temp;
    }
  }
  void display()
  {
    struct node *q;
    if (start==NULL)
    {cout<<"List Empty";
    }
    q=start;
    while(q!=NULL)
    {
      cout<<q->info<<endl;
      q=q->link;
    }
  }
  void rev()
  {
    struct node *p1,*p2,*p3;
     if(start==NULL)
     {
       return ;
     }
     p1=start;
     p2=p1->link;
     p3=p2->link;
     p1->link=NULL;
     p2->link= p1;
     while(p3!=NULL)
     {
    p1=p2;
    p2=p3;
    p3=p3->link;
    p2->link=p1;
     }
     start=p2;
  }
  void insert(int data,int pos)
  {
     struct node *temp,*q;
    
     q=start;
     for(int i=0;i<pos-1;i++)
      {
    q=q->link;
      if(q==NULL)
      {
                 cout<<"There are less emelents "<<pos;
                 }
                 }
      temp=(node*)malloc(sizeof(struct node));
     temp->info=data;
     temp->link=q->link;
      q->link=temp;
  }
  void del(int data)
{
    struct node *tmp,*q;
    if(start->info==data)
    {
        tmp=start;
        start=start->link;    /*first element deleted*/
        free(tmp);
        return;
    }
    q=start;
    while(q->link->link!=NULL)
    {
        if(q->link->info==data)           /*element deleted in between*/
        {
            tmp=q->link;
            q->link=tmp->link;
            free(tmp);
            cout<<"Deleted "<<data<<endl;
            return;
        }
        q=q->link;
    }
    if(q->link->info==data)
    {
        tmp=q->link;
        free(tmp);
        q->link=NULL;
        return;
    }
    cout<<"Element "<<data<<" not found"<<endl;
}

Friday, January 9, 2015

How to setup Chitika on Blogger and Wordpress

Chitika is another way to earn money out of your blog.Once you already have a Publisher account on Chitika, you can also earn money by promoting their advertisers' ads on your blog. Chitika ads are mainly texts ads and can be put side by side with the Google Adsense ads. If you wanted to blog for money with Chitika, follow the simple steps below.
Chitika is a search-targeted advertising network that can help you monetize your business's website by placing targeted ad banners throughout the site. These ads then generate revenue for you whenever site visitors click them.

Steps

  1. Click here to  to signup www.chitika.com.
  2. Fill the application form .
  3. After submitting the application form, a message saying "Your application has been submitted for review" will appear. See the image below.
  4. Now go to your email and click the VERIFICATION LINK. After clicking the link the image below will appear. Input your valid address and the Description of your blog. After that click the SUBMIT button.
  5. Wait about a day to know whether Chitika approved or disapproved your blog Publisher application. Assuming that your blog is APPROVED. Log in on your Chitika publisher account.Go to AD SETUP > TYPES OF ADS > TEXT ADS. See the image below.
  6. When you are in the CODE GENERATOR, you can customize your CHITIKA AD there. You can also change the AD SIZE in FORMAT. When you are done customizing your ad, click the GET CODE button.  
  7. Now COPY and PASTE your Chitika Ad Code in your blog. Go to LAYOUT > ADD A GADGET > HTML/JavaScript. 
    For wordpress you can install new plugins and then go to settings and change ads display.
    For blogger you have to get code from Chitika Getcode option from Ad Settings. 
    • Then go to layout and click Add new gadget > HTML/JAVASCRIPT. 
    • Copy the code from Chitika and paste here.
    •  Save arrangements. 
    • Now Chitika ads will display on your blog.
     

Make Money By Translating

If you can speak two or more languages and can translate. Then don't wait this offer is only for you. Signup and start working from home full or part time.
RealTranslatorJobs.com allows people all over the world who speak two language to make money online translating for companies, translating websites into other languages and more!
With extremely high conversion rates, very effective email campaigns and attractive graphics that are proven to draw clicks; promoting RealTranslatorJobs.com is practically guaranteed to make you some great money!
Go to their website www.realtranslatorjobs.com and signup and start making money.