L4-Linked data structure link list and details.ppt

pallabistu2017 0 views 35 slides Oct 12, 2025
Slide 1
Slide 1 of 35
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35

About This Presentation

Linked data structure link list and details


Slide Content

Linked ListsLinked Lists

Menu
CSE@DIUCSE@DIU
struct node {
int data;
struct node* next;
};
typedef struct node Node;
typedef struct node* List;
List Initialize();
void InsertBegin(List l,int d);
void InsertEnd(List l, int d);
void Insert(List l, Node* pos,int d);
Node* Find(List l,int d);
void Delete(List l, int d);

Menu
CSE@DIUCSE@DIU
MenuMenu
Initialize
InsertBegin
InsertEnd
Insert
Find
Delete

Menu
CSE@DIUCSE@DIU
InitializeInitialize

Menu
CSE@DIUCSE@DIU
List Initialize()
{
Node* temp;
temp = (Node*)calloc(1,sizeof(Node));
return temp;
}

Menu
CSE@DIUCSE@DIU
List Initialize()
{
Node* temp;
temp = (Node*)calloc(1,sizeof(Node));
return temp;
}
X
head
main()
{
List head;
head = Initialize();
}

Menu
CSE@DIUCSE@DIU
InsertBeginInsertBegin

Menu
CSE@DIUCSE@DIU
X
head
110846325

Menu
CSE@DIUCSE@DIU
X
head
110846325
void InsertBegin(List head,int d)
{
Node* temp;
temp = (Node*)calloc(1,sizeof(Node));
temp->data = d;
temp->next = head->next;
head->next = temp;
}

Menu
CSE@DIUCSE@DIU
X
head
110846325
void InsertBegin(List head,int d)
{
Node* temp;
temp = (Node*)calloc(1,sizeof(Node));
temp->data = d;
temp->next = head->next;
head->next = temp;
}
1

Menu
CSE@DIUCSE@DIU
X
head
110846325
1

Menu
CSE@DIUCSE@DIU
110846325
void InsertBegin(List head,int d)
{
Node* temp;
temp = (Node*)calloc(1,sizeof(Node));
temp->data = d;
temp->next = head->next;
head->next = temp;
}
X
head
1

Menu
CSE@DIUCSE@DIU
110846325
void InsertBegin(List head,int d)
{
Node* temp;
temp = (Node*)calloc(1,sizeof(Node));
temp->data = d;
temp->next = head->next;
head->next = temp;
}
X
head
1

Menu
CSE@DIUCSE@DIU
110846325
void InsertBegin(List head,int d)
{
Node* temp;
temp = (Node*)calloc(1,sizeof(Node));
temp->data = d;
head->next = temp;
temp->next = head->next;
}
X
head
1

Menu
CSE@DIUCSE@DIU
X
head
110846325
1
void InsertBegin(List head,int d)
{
Node* temp;
temp = (Node*)calloc(1,sizeof(Node));
temp->data = d;
temp->next = head->next;
head->next = temp;
}

Menu
CSE@DIUCSE@DIU
X
head
110846325
1
10
void InsertBegin(List head,int d)
{
Node* temp;
temp = (Node*)calloc(1,sizeof(Node));
temp->data = d;
temp->next = head->next;
head->next = temp;
}

Menu
CSE@DIUCSE@DIU
X
head
110846325
1
10
void InsertBegin(List head,int d)
{
Node* temp;
temp = (Node*)calloc(1,sizeof(Node));
temp->data = d;
head->next = temp;
temp->next = head->next;
}

Menu
CSE@DIUCSE@DIU
InsertEndInsertEnd

Menu
CSE@DIUCSE@DIU
X
head
110846325
10 1
void InsertEnd(List head,int d)
{
Node *tail,*temp;
tail = head;
. . . . . . . .
. . . . . . . .
}
tail

Menu
CSE@DIUCSE@DIU
110846325
void InsertEnd(List head,int d)
{
Node *tail,*temp;
tail = head;
while(tail->next != NULL)
tail = tail->next;
. . . . . . . .
. . . . . . . .
}
X
head
10 1
tail

Menu
CSE@DIUCSE@DIU
110846325
void InsertEnd(List head,int d)
{
Node *tail,*temp;
tail = head;
while(tail->next != NULL)
tail = tail->next;
. . . . . . . .
. . . . . . . .
}
X
head
10 1
tail

Menu
CSE@DIUCSE@DIU
X
head
110846325
10 1
void InsertEnd(List head,int d)
{
. . . . . . . .
. . . . . . . .
temp = (Node*)calloc(1,sizeof(Node));
temp->data = d;
tail->next = temp;
}
8
tail

Menu
CSE@DIUCSE@DIU
InsertInsert

Menu
CSE@DIUCSE@DIU
X
head
110846325
10 1 8
void Insert(List head,Node* p,int d)
{
temp = (Node*)calloc(1,sizeof(Node));
temp->data = d;
temp->next = p->next;
p->next = temp;
}

Menu
CSE@DIUCSE@DIU
X
head
110846325
10 1 8
4
void Insert(List head,Node* p,int d)
{
temp = (Node*)calloc(1,sizeof(Node));
temp->data = d;
temp->next = p->next;
p->next = temp;
}

Menu
CSE@DIUCSE@DIU
X
head
110846325
10 1 4 8

Menu
CSE@DIUCSE@DIU
FindFind

Menu
CSE@DIUCSE@DIU
X
head
110846325
10 1 4 8
void Find(List l,Node* p,int d)
{
Node *temp;
temp = l;
while(temp->next != NULL)
{
if(temp->next->data == d)
return temp;
temp = temp->next;
}
return NULL;
}

Menu
CSE@DIUCSE@DIU
X
head
110846325
10 1 4 8
void Find(List l,Node* p,int d)
{
Node *temp;
temp = l;
while(temp->next != NULL)
{
if(temp->next->data == d)
return temp;
temp = temp->next;
}
return NULL;
}
temp

Menu
CSE@DIUCSE@DIU
DeleteDelete

Menu
CSE@DIUCSE@DIU
X
head
110846325
10 41 8
void Delete(List l,Node* p,int d)
{
Node *temp,*del;
temp = Find(l,d);
if(temp != NULL)
{
del = temp->next;
temp->next = del->next;
free(del);
}
}

Menu
CSE@DIUCSE@DIU
X
head
110846325
10 41 8
void Delete(List l,Node* p,int d)
{
Node *temp,*del;
temp = Find(l,d);
if(temp != NULL)
{
del = temp->next;
temp->next = del->next;
free(del);
}
}
temp del

Menu
CSE@DIUCSE@DIU
X
head
10846325
10 4 8

Menu
CSE@DIUCSE@DIU
int main
{
List l;
Node* temp;
l = Initialize();
InsertBegin(l,1);
InsertBegin(l,10);
InsertEnd(l,8);
temp = Find(l,8);
Insert(l,temp,4);
Delete(l,1);
}

Menu
CSE@DIUCSE@DIU
Enjoy Linking You in ListEnjoy Linking You in List