Download - Linked lists
![Page 2: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/2.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
Menustruct 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);
![Page 3: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/3.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
MenuMenuMenu
InitializeInitialize
InsertBeginInsertBegin
InsertEndInsertEnd
InsertInsert
FindFind
DeleteDelete
![Page 4: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/4.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
Menu
InitializeInitialize
![Page 5: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/5.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
Menu
List Initialize()
{
Node* temp;
temp = (Node*)calloc(1,sizeof(Node));
return temp;
}
![Page 6: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/6.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
Menu
List Initialize()
{
Node* temp;
temp = (Node*)calloc(1,sizeof(Node));
return temp;
}
X
head
main()
{
List head;
head = Initialize();
}
![Page 7: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/7.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
Menu
InsertBeginInsertBegin
![Page 8: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/8.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
Menu
X
head
1 10 8 4 6 3 2 5
![Page 9: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/9.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
Menu
X
head
1 10 8 4 6 3 2 5
void InsertBegin(List head,int d)
{
Node* temp;
temp = (Node*)calloc(1,sizeof(Node));
temp->data = d;
temp->next = head->next;
head->next = temp;
}
![Page 10: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/10.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
Menu
X
head
1 10 8 4 6 3 2 5
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
![Page 11: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/11.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
Menu
X
head
1 10 8 4 6 3 2 5
1
![Page 12: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/12.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
Menu1 10 8 4 6 3 2 5
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
![Page 13: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/13.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
Menu1 10 8 4 6 3 2 5
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
![Page 14: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/14.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
Menu1 10 8 4 6 3 2 5
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
![Page 15: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/15.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
Menu
X
head
1 10 8 4 6 3 2 5
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;
}
![Page 16: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/16.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
Menu
X
head
1 10 8 4 6 3 2 5
1
10void InsertBegin(List head,int d)
{
Node* temp;
temp = (Node*)calloc(1,sizeof(Node));
temp->data = d;
temp->next = head->next;
head->next = temp;
}
![Page 17: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/17.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
Menu
X
head
1 10 8 4 6 3 2 5
1
10void InsertBegin(List head,int d)
{
Node* temp;
temp = (Node*)calloc(1,sizeof(Node));
temp->data = d;
head->next = temp;
temp->next = head->next;
}
![Page 18: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/18.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
Menu
InsertEndInsertEnd
![Page 19: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/19.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
Menu
X
head
1 10 8 4 6 3 2 5
10 1
void InsertEnd(List head,int d){
Node *tail,*temp;tail = head;. . . . . . . .. . . . . . . .
}
tail
![Page 20: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/20.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
Menu1 10 8 4 6 3 2 5
void InsertEnd(List head,int d){
Node *tail,*temp;tail = head;while(tail->next != NULL)
tail = tail->next;. . . . . . . .. . . . . . . .
}
X
head
10 1
tail
![Page 21: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/21.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
Menu1 10 8 4 6 3 2 5
void InsertEnd(List head,int d){
Node *tail,*temp;tail = head;while(tail->next != NULL)
tail = tail->next;. . . . . . . .. . . . . . . .
}
X
head
10 1
tail
![Page 22: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/22.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
Menu
X
head
1 10 8 4 6 3 2 5
10 1
void InsertEnd(List head,int d){
. . . . . . . .
. . . . . . . . temp =
(Node*)calloc(1,sizeof(Node));temp->data = d;
tail->next = temp;
}
8
tail
![Page 23: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/23.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
Menu
InsertInsert
![Page 24: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/24.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
Menu
X
head
1 10 8 4 6 3 2 5
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;
}
![Page 25: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/25.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
Menu
X
head
1 10 8 4 6 3 2 5
10 1 8
4void Insert(List head,Node* p,int d){
temp = (Node*)calloc(1,sizeof(Node));
temp->data = d;
temp->next = p->next;p->next = temp;
}
![Page 26: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/26.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
Menu
X
head
1 10 8 4 6 3 2 5
10 1 4 8
![Page 27: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/27.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
Menu
FindFind
![Page 28: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/28.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
Menu
X
head
1 10 8 4 6 3 2 5
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;
}
![Page 29: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/29.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
Menu
X
head
1 10 8 4 6 3 2 5
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
![Page 30: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/30.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
Menu
DeleteDelete
![Page 31: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/31.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
Menu
X
head
1 10 8 4 6 3 2 5
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);
}}
![Page 32: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/32.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
Menu
X
head
1 10 8 4 6 3 2 5
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
![Page 33: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/33.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
Menu
X
head
10 8 4 6 3 2 5
10 4 8
![Page 34: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/34.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
Menu
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);
}
![Page 35: Linked lists](https://reader036.vdocuments.mx/reader036/viewer/2022062513/55509a4fb4c9058b208b4885/html5/thumbnails/35.jpg)
April 12, 2023April 12, 2023 http://www.gowrikumar.comhttp://www.gowrikumar.com
Menu
The EndThe End