Thursday, January 15, 2015

Implementation of Stack by linklist

#include <iostream>
#include<stdio.h>
#include <conio.h>
using namespace std;
struct node
{
    int info;
    struct node *ptr;
}*top,*top1,*temp;

int topelement();
void push(int data);
void pop();
void display();
void destroy();
void create();
int count = 0;
int main()
{
    int no, ch, e;
    printf("\n 1 - Push");
    printf("\n 2 - Pop");
    printf("\n 3 - Top");
    printf("\n 4 - Empty");
    printf("\n 5 - Exit");
    printf("\n 6 - Dipslay");
    printf("\n 7 - Stack Count");
    printf("\n 8 - Destroy stack");
    create();
    while (1)
    {
        printf("\n Enter choice : ");
        scanf("%d", &ch);
        switch (ch)
        {
        case 1:
            printf("Enter data : ");
            scanf("%d", &no);
            push(no);
            break;
        case 2:
            pop();
            break;
        case 3:
            if (top == NULL)
                printf("No elements in stack");
            else
            {
                e = topelement();
                printf("\n Top element : %d", e);
            }
           
            break;
        case 4:
            exit(0);
        case 5:
            display();
            break;
        default :
            printf(" Wrong choice, Please enter correct choice  ");
            break;
        }
    }
}

/* Create empty stack */
void create()
{
    top = NULL;
}

/* Count stack elements */


/* Push data into stack */
void push(int data)
{
    if (top == NULL)
    {
        top =(struct node *)malloc(1*sizeof(struct node));
        top->ptr = NULL;
        top->info = data;
    }
    else
    {
        temp =(struct node *)malloc(1*sizeof(struct node));
        temp->ptr = top;
        temp->info = data;
        top = temp;
    }

}

/* Display stack elements */
void display()
{
    top1 = top;

    if (top1 == NULL)
    {
        printf("Stack is empty");
        return;
    }

    while (top1 != NULL)
    {
        printf("%d ", top1->info);
        top1 = top1->ptr;
    }
 }

/* Pop Operation on stack */
void pop()
{
    top1 = top;

    if (top1 == NULL)
    {
        printf("\n Error : Trying to pop from empty stack");
        return;
    }
    else
        top1 = top1->ptr;
    printf("\n Popped value : %d", top->info);
    free(top);
    top = top1;

}

/* Return top element */
int topelement()
{
    return(top->info);
}

How to implement Binary Search Tree and show output as Inorder, Preorder and Post Order?

#include<conio.h>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
using namespace std;
struct node
{
struct node *lchild,*rchild;
int info;
}*root;
void find(int,struct node **,struct node **);
void insert(int);
void del(int);
void case_a(struct node*,struct node*);
void case_b(struct node*,struct node*);
void case_c(struct node*,struct node*);
void preorder(struct node *);
void inorder(struct node *);
void postorder(struct node *);
main()
{
int choice,num;
root=NULL;
while(1)
{
cout<<"\n";
cout<<"1.INSERT"<<endl;
cout<<"2. DELETE"<<endl;
cout<<"3. INORDER TRAVERSAL"<<endl;
cout<<"4. PREORDER TRAVERSAL"<<endl;
cout<<"5. POSTORDER TRAVERSAL"<<endl;
cout<<"6. QUIT"<<endl;
cout<<"enter your choice"<<endl;
cin>>choice;
switch(choice)
{
case 1:
cout<<"Enter the number to be inserted"<<endl;
cin>>num;
insert(num);
break;
case 2:
cout<<"Enter the number to be deleted"<<endl;
cin>>num;
del(num);
break;
case 3:
inorder(root);
break;
case 4:
preorder(root);
break;
case 5:
postorder(root);
break;
case 6:
exit(1);
default:
cout<<"WRONG CHOICE"<<endl;
}
}
}
void find(int item,struct node**par,struct node**loc)
{
struct node *ptr,*ptrsave;
if(root==NULL)
{
*loc=NULL;
*par=NULL;
return;
}
if(item==root->info)
{
*loc=root;
*par=NULL;
return;
}
if(item<root->info)
ptr=root->lchild;
else
ptr=root->rchild;
ptrsave=root;
while(ptr!=NULL)
{
if(item==ptr->info)
{
*loc=ptr;
*par=ptrsave;
return;
}
ptrsave=ptr;
if(item<ptr->info)
ptr=ptr->lchild;
else
ptr=ptr->rchild;
}
*loc=NULL;
*par=ptrsave;
}
void insert(int item)
{
struct node *tmp,*parent,*location;
find(item,&parent,&location);
if(location!=NULL)
{
cout<<"Item Is Already Present"<<endl;
return;
}
tmp=new(struct node);
tmp->info=item;
tmp->lchild=NULL;
tmp->rchild=NULL;
if(parent==NULL)
root=tmp;
else
if(item<parent->info)
parent->lchild=tmp;
else
parent->rchild=tmp;
}
void del(int item)
{
struct node *parent,*location;
if(root==NULL)
{
cout<<"TREE EMPTY"<<endl;
return;
}
find(item,&parent,&location);
if(location==NULL)
{
cout<<"item not presented in the tree"<<endl;
return;
}
if(location->lchild==NULL&&location->rchild==NULL)
case_a(parent,location);
if(location->lchild!=NULL&&location->rchild==NULL)
/*case_b(parent,location);
if(location->lchild==NULL&&location->rchild!=NULL)
case_b(parent,location);
if(location->lchild!=NULL&&location->rchild!=NULL)
case_c(parent,location);*/
free(location);
}
void case_a(struct node *par,struct node *loc)
{
if(par==NULL)
root=NULL;
else
if(loc==par->lchild)
par->lchild=NULL;
else
par->rchild=NULL;
}
void case_b(struct node *par,struct node *loc)
{
struct node *child;
if(loc->lchild!=NULL)
child=loc->lchild;
else
child=loc->rchild;
if(par==NULL)
root=child;
else
if(loc==par->lchild)
par->lchild=child;
else
par->rchild=child;
}
void case_c(struct node *par,struct node *loc)
{
struct node *ptr,*ptrsave,*suc,*parsuc;
ptrsave=loc;
ptr=loc->rchild;
while(ptr->lchild!=NULL)
{
ptrsave=ptr;
ptr=ptr->lchild;
}
suc=ptr;
parsuc=ptrsave;
if(suc->lchild==NULL&&suc->rchild==NULL)
case_a(parsuc,suc);
else
case_b(parsuc,suc);
if(par==NULL)
root=suc;
else
if(loc==par->lchild)
par->lchild=suc;
else
par->rchild=suc;
suc->lchild=loc->lchild;
suc->rchild=loc->rchild;
}
void preorder(struct node *ptr)
{
if(root==NULL)
{
cout<<"TREE IS EMPTY"<<endl;
return;
}
if(ptr!=NULL)
{
cout<<ptr->info<<"\t";
preorder(ptr->lchild);
preorder(ptr->rchild);
}
}
void inorder(struct node *ptr)
{
if(root==NULL)
{
cout<<"TREE IS EMPTY"<<endl;
return;
}
if(ptr!=NULL)
{
inorder(ptr->lchild);
cout<<ptr->info<<"\t";
inorder(ptr->rchild);
}
}
void postorder(struct node *ptr)
{
if(root==NULL)
{
cout<<"TREE IS EMPTY"<<endl;
return;
}
if(ptr!=NULL)
{
postorder(ptr->lchild);
postorder(ptr->rchild);
cout<<ptr->info<<"\t";
}
}



How to implement Stack by Array in C++?

#include<iostream>
#include<conio.h>
#include<stdio.h>
//#include<stack>
using namespace std;


#define max 5
int Stack_Array[max];
int top=-1;
void push();
void pop();
void display();

main()
{
int choice;
while(1)
{
cout<<"1: Push"<<endl;
cout<<"2: Pop"<<endl;
cout<<"3: Display"<<endl;
cout<<"4:Quit"<<endl;
cin>>choice;

switch(choice)
{
case 1:
push();
break;

case 2:
pop();
break;

case 3:
display();
break;

case 4:
return 0;;

default:
cout<<"Wrong Choice"<<endl;

}  //end of switch
}  //end of while
}   //end of main

void push()
{
int pushed_item;
if(top==(max-1))
    cout<<"Stack_Array Overflow"<<endl;
else
{
    cout<<"Enter the item to be pushed in Stack_Array:"<<endl;
    cin>>pushed_item;
    top=top+1;
    Stack_Array[top]=pushed_item;

}
}


void pop()
{
if(top==-1)
    cout<<"Stack_Array Underflow"<<endl;
else
{
    cout<<"Poped element is:"<<Stack_Array[top]<<endl;
    top=top-1;
}
}


void display()
{
int i;
if(top==-1)
    cout<<"Stack_Array Empty"<<endl;
else
{
    cout<<"Stack_Array element:"<<endl;
    for(i=top;i>=0;i--)
    cout<<Stack_Array[i]<<endl;
}
}

How to implement Circular Queue By Linklist?

//Circular Queue Through Linklists
#include<iostream>
#define SIZE 100
#include<conio.h>
using namespace std;
struct circularque
{
  int data;
  struct circularque *next;
}*f=NULL,*r=NULL,*n,*temp,*temp1;

void insert();
void delet();
void display();

int main()
{
  int ch;
  do
  {
     cout<<"\n\n\tMain Menu";
     cout<<"\n****************************";
     cout<<"\n1. Insert\n2. Delete\n3. Display\n4. Exit\n\nEnter Your Choice: ";
     cin>>ch;
     switch(ch)
     {
    case 1:
      insert();
      display();
      break;
    case 2:
      delet();
      break;
    case 3:
    display();
      break;
      case 4:
    default:
      cout<<"\n\nWrong Choice!!! Try Again.";
     }
  }while(ch!=4);
  return 0;
}

void insert()
{
  n=new circularque[sizeof(circularque)];
  cout<<"\nEnter the Element: ";
  cin>>n->data;
  if(f==NULL)
  {
      f=n;
  }
  else
  {
      r->next=n;
  }
  r=n;
  r->next=f;
}
void delet()
{
  int x;
  temp=f;
  if(f==NULL)
  {
      cout<<"\nCircular Queue Empty!!!";
  }
  else
  {
     if(f==r)
     {
       x=f->data;
       delete(temp);
       f=NULL;
       r=NULL;
     }
     else
     {
    x=temp->data;
    f=f->next;
    r->next=f;
    delete(temp);
     }
     cout<<"\nElement "<<x<<" is Deleted";
     display();
  }
}
void display()
{
  temp=f;
  temp1=NULL;
  if(f==NULL)
  {
    cout<<"\n\nCircular Queue Empty!!!";
  }
  else
  {
    cout<<"\n\nCircular Queue Elements are:\n\n";
    while(temp!=temp1)
    {
       cout<<temp->data<<"  ";
       temp=temp->next;
       temp1=f;
    }
  }
}

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.