-
Notifications
You must be signed in to change notification settings - Fork 253
/
Doubly Link List DS.c
68 lines (64 loc) · 1.03 KB
/
Doubly Link List DS.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include<stdio.h>
#include<conio.h>
struct node
{
int info;
struct node *lptr;
struct node *rptr;
};
struct node FIRST;
void insertbeg()
{
struct node *newnode;
printf("Enter Value to Insert: ");
scanf("%d",&newnode->info);
newnode->lptr;
if(FIRST==NULL)
{
newnode->rptr=NULL;
FIRST=newnode;
}
else
{
newnode->rptr=FIRST;
FIRST=newnode;
}
printf("Node Inserted.")
}
void insertend()
{
struct node *newnode,*temp;
printf("Enter Value to Insert: ");
scanf("%d",&newnode->info);
newnode->rptr=NULL;
if(FIRST==NULL)
{
newnode->lptr=NULL;
FIRST=newnode;
}
else
{
temp=FIRST;
while(temp->rptr!=NULL)
temp=temp->rptr;
temp->rptr=newnode;
newnode->lptr=temp;
}
printf("Node Inserted.s")
}
void deletebeg()
{
if(FIRST==NULL)
printf("List is Empty.")
else if(FIRST->rptr==NULL)
{
printf("Deleted node: %d",FIRST->info);
FIRST=NULL;
}
else
{
printf("Deleted node: %d",FIRST->info);
FIRST=FIRST->rptr;
FIRST->lptr=NULL
}
}