15-11-2012, 04:06 PM
LINKED LIST IMPLEMENTATION OF SINGLY LINKED LIST
LINKED LIST IMPLEMENTATION OF SINGLY LINKED LIST.docx (Size: 14.1 KB / Downloads: 21)
Algorithm:
Step 1: initialize the list as null
Step 2: Display linked list operations insert, delete and display the result.
Step 3: If choice is 1 the read element to be inserted and call the insert function
Step 4: If choice is 2 then read element to be deleted and call the delete function
Step 5: If choice is 3 then call display function
Step 6: If choice is default the exit the program.
Program:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void insert(int x);
void deletion(int x);
void display();
struct node
{
int element;
struct node *next;
}*list=NULL,*p;
struct node *find(int s)
{
p=list->next;
while(p!=NULL && p->element!=s)
p=p->next;
return p;
}
struct node *findprevious(int s)
{
p=list;
while(p->next!=NULL && p->next->element!=s)
p=p->next;
return p;