Skip to main content

Posts

Showing posts from June, 2009

DS Extra programs_July 09

  /*1. WAP to implement searching in a linked list */   #include<iostream.h> #include<conio.h> #include<process.h>   class node {   int data;   node *next;   public:   void insert();   void search(int);   void display(); };   node *start,*head,*temp;   void node::insert() {   head=new node;   cout<<"\n Enter the data item: ";   cin>>head->data;   head->next=NULL;   if(start==NULL)   {   start=head;   }   else   {   temp=start;   while(temp->next!=NULL)   {    temp=temp->next;   }   temp->next=head;   } }   void node::display() {   temp=start;   if(start==NULL)   cout<<"\n Data list is empty ";   else   {   cout<<"\n DATA LIST: ";   while(temp!=NULL)   {    cout<<temp->data<<" ";    temp=temp->next;   }   } }   void node::search(int data) {   temp=start;   if(start==NULL)   cout<<"\n Data list is empty ...