SlideShare a Scribd company logo
1 of 32
International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 1
-Varsha Degaonkar
www.isquareit.edu.in
International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
2
International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 3
INTRODUCTION
SINGLY LINKED LIST (SLL):
• Singly Linked List is collection of data elements.
• Each element represents a node in SLL.
• Each node consists of
one or more data fields and
one address field which stores the address of next node.
• Operations in SLL:
Creation
Insertion
Display
SINGLY LINKED LIST
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
typedef struct sll
{ int data;
struct sll *next;
}sll;
International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 4
Structure
definition
Creation of user
defined data
type.
SINGLY LINKED LIST
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
typedef struct sll
{ int data;
struct sll *next;
}sll;
void main()
{
int op;
sll *head=NULL;
clrscr();
International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 5
Pointer variable declaration of the
Structure and assigning value to it
data *next
Node of SLL:
sll *create(sll *); /*function declaration*/
sll *insert(sll *); /*function declaration*/
void disp(sll *); /*function declaration*/
do // menu driven program
{
printf("1)Createn2)Insertn3) Displayn4)Exit");
printf("nEnter the option: ");
scanf("%d",&op);
switch(op)
{
International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 6
case 1:
head=create(head);
/*Function Call*/
break;
International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 7
sll *create(sll *head)
{
sll *p,*nw;
char ans;
do
{
nw=(sll*)malloc(sizeof(sll));nw=500
case 1:
head=create(head);
/*Function Call*/
break;
International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 8
sll *create(sll *head)
{
sll *p,*nw;
char ans;
do
{
nw=(sll*)malloc(sizeof(sll));
nw->next=NULL;
NULL
nw=500
case 1:
head=create(head);
/*Function Call*/
break;
International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 9
sll *create(sll *head)
{
sll *p,*nw;
char ans;
do
{
nw=(sll*)malloc(sizeof(sll));
nw->next=NULL;
printf("nEnter the data:");
scanf("%d",&(nw->data));
NULL10
nw=500
case 1:
head=create(head);
/*Function Call*/
break;
International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 10
sll *create(sll *head)
{
sll *p,*nw;
char ans;
do
{
nw=(sll*)malloc(sizeof(sll));
nw->next=NULL;
printf("nEnter the data:");
scanf("%d",&(nw->data));
if(head==NULL)
NULL10
nw=500
case 1:
head=create(head);
/*Function Call*/
break;
International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email -
info@isquareit.edu.in 11
sll *create(sll *head)
{
sll *p,*nw;
char ans;
do
{
nw=(sll*)malloc(sizeof(sll));
nw->next=NULL;
printf("nEnter the data:");
scanf("%d",&(nw->data));
if(head==NULL)
p=head=nw;
NULL10
p=head=nw=500
case 1:
head=create(head);
/*Function Call*/
break;
International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
12
sll *create(sll *head)
{
sll *p,*nw;
char ans;
do
{
nw=(sll*)malloc(sizeof(sll));
nw->next=NULL;
printf("nEnter the data:");
scanf("%d",&(nw->data));
if(head==NULL)
p=head=nw;
else
NULL10
p =head=500
NULL20
nw=600
case 1:
head=create(head);
/*Function Call*/
break;
International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
13
sll *create(sll *head)
{
sll *p,*nw;
char ans;
do
{
nw=(sll*)malloc(sizeof(sll));
nw->next=NULL;
printf("nEnter the data:");
scanf("%d",&(nw->data));
if(head==NULL)
p=head=nw;
else
{
p->next=nw;
60010
p=head=500
NULL20
nw=600
case 1:
head=create(head);
/*Function Call*/
break;
International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 14
sll *create(sll *head)
{
sll *p,*nw;
char ans;
do
{
nw=(sll*)malloc(sizeof(sll));
nw->next=NULL;
printf("nEnter the data:");
scanf("%d",&(nw->data));
if(head==NULL)
p=head=nw;
else
{
p->next=nw;
p=nw;
}
60010
p=head=500
NULL20
p=nw=600
case 1:
head=create(head);
/*Function Call*/
break;
International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 15
sll *create(sll *head)
{
sll *p,*nw;
char ans;
do
{ nw=(sll*)malloc(sizeof(sll));
nw->next=NULL;
printf("nEnter the data:");
scanf("%d",&(nw->data));
if(head==NULL)
p=head=nw;
else
{ p->next=nw;
p=nw;
}
printf("nt Do you want to insert node(Y/N)"); flushall();
scanf("%c",&ans);
}while(ans=='y'||ans=='Y');
return(head);
}
60010
head=500
NULL20
p=600
NULL30
nw=700
case 1:
head=create(head);
/*Function Call*/
break;
International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 16
sll *create(sll *head)
{
sll *p,*nw;
char ans;
do
{ nw=(sll*)malloc(sizeof(sll));
nw->next=NULL;
printf("nEnter the data:");
scanf("%d",&(nw->data));
if(head==NULL)
p=head=nw;
else
{ p->next=nw;
p=nw;
}
printf("nt Do you want to insert node(Y/N)"); flushall();
scanf("%c",&ans);
}while(ans=='y'||ans=='Y');
return(head);
}
60010
head=500
70020
p=600
NULL30
nw=700
case 1:
head=create(head);
/*Function Call*/
break;
International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 17
sll *create(sll *head)
{
sll *p,*nw;
char ans;
do
{ nw=(sll*)malloc(sizeof(sll));
nw->next=NULL;
printf("nEnter the data:");
scanf("%d",&(nw->data));
if(head==NULL)
p=head=nw;
else
{ p->next=nw;
p=nw;
}
printf("nt Do you want to insert node(Y/N)"); flushall();
scanf("%c",&ans);
}while(ans=='y'||ans=='Y');
return(head);
}
60010
head=500
70020
p=600
NULL30
p=nw=700
case 2:
head= insert(head);
break;
International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 18
sll *insert(sll *head)
{ sll *p,*q;
int loc,i;
printf("nEnter the location:");
scanf("%d",&loc); //enter location for node insertion
p=(sll*)malloc(sizeof(sll)); //create new node
printf("nenter a data:"); //enter data in node
scanf("%d",&(p->data));
if(loc==1) //Insertion as head node i.e. if position is 1
{
p->next=head;
head=p;
return(head);
}
60010
head=500
70020
600
NULL30
700
case 2:
head= insert(head);
break;
International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 19
sll *insert(sll *head)
{ sll *p,*q;
int loc,i;
printf("nEnter the location:");
scanf("%d",&loc); //enter location for node insertion
p=(sll*)malloc(sizeof(sll)); //create new node
printf("nenter a data:"); //enter data in node
scanf("%d",&(p->data));
if(loc==1) //Insertion as head node i.e. if position is 1
{
p->next=head;
head=p;
return(head);
}
60010
head=500
70020
600
NULL30
700
5
P=400
case 2:
head= insert(head);
break;
International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 20
sll *insert(sll *head)
{ sll *p,*q;
int loc,i;
printf("nEnter the location:");
scanf("%d",&loc); //enter location for node insertion
p=(sll*)malloc(sizeof(sll)); //create new node
printf("nenter a data:"); //enter data in node
scanf("%d",&(p->data));
if(loc==1) //Insertion as head node i.e. if position is 1
{
p->next=head;
head=p;
return(head);
}
60010
head=500
70020
600
NULL30
700
5005
p=head=400
case 2:
head= insert(head);
break;
International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
21
else // if insertion is at other position than head node
{
i=1;q=head;
while(i<loc-1)
{
q=q->next;
i++;
}
p->next=q->next;
q->next=p;
}
disp(head);
return(head);
}
60010
q=head=500
70020
600
NULL30
700
NULL25
p=750
case 2:
head= insert(head);
break;
International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 22
else // if insertion is at other position than head node
{
i=1;q=head;
while(i<loc-1)
{
q=q->next;
i++;
}
p->next=q->next;
q->next=p;
}
disp(head);
return(head);
}
60010
q=head=500
70020
q=600
NULL30
700
NULL25
p=750
case 2:
head= insert(head);
break;
International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 23
else // if insertion is at other position than head node
{
i=1;q=head;
while(i<loc-1)
{
q=q->next;
i++;
}
p->next=q->next;
q->next=p;
}
disp(head);
return(head);
}
60010
q=head=500
70020
q=600
NULL30
700
70025
p=750
case 2:
head= insert(head);
break;
International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 24
else // if insertion is at other position than head node
{
i=1;q=head;
while(i<loc-1)
{
q=q->next;
i++;
}
p->next=q->next;
q->next=p;
}
disp(head);
return(head);
}
60010
q=head=500
75020
q=600
NULL30
700
70025
p=750
case 3:
head= disp(head);
break;
International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
25
void disp(sll *head)
{
sll *p;
if(head==NULL)//if linked list is not created
printf("nEmpty Linked List");
else
{
printf("nn Created SLL:nn ");
for(p=head;p!=NULL;p=p->next)
printf("%d->",p->data);
printf("NULL");
}
}
60010
head=500
70020
600
NULL30
700
case 3:
head= disp(head);
break;
International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 26
void disp(sll *head)
{
sll *p;
if(head==NULL)//if linked list is not created
printf("nEmpty Linked List");
else
{
printf("nn Created SLL:nn ");
for(p=head;p!=NULL;p=p->next)
printf("%d->",p->data);
printf("NULL");
}
}
60010
p=head=500
70020
600
10->
NULL30
700
case 3:
head= disp(head);
break;
International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 27
60010
p=head=500
70020
p=600
10->20->
NULL30
700
void disp(sll *head)
{
sll *p;
if(head==NULL)//if linked list is not created
printf("nEmpty Linked List");
else
{
printf("nn Created SLL:nn ");
for(p=head;p!=NULL;p=p->next)
printf("%d->",p->data);
printf("NULL");
}
}
case 3:
head= disp(head);
break;
International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 28
60010
p=head=500
70020
p=600
10->20->30->
NULL30
p=700
void disp(sll *head)
{
sll *p;
if(head==NULL)//if linked list is not created
printf("nEmpty Linked List");
else
{
printf("nn Created SLL:nn ");
for(p=head;p!=NULL;p=p->next)
printf("%d->",p->data);
printf("NULL");
}
}
case 3:
head= disp(head);
break;
International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 29
60010
p=head=500
70020
p=600
10->20->30-> NULL
NULL30
p=700 p=NULL
void disp(sll *head)
{
sll *p;
if(head==NULL)//if linked list is not created
printf("nEmpty Linked List");
else
{
printf("nn Created SLL:nn ");
for(p=head;p!=NULL;p=p->next)
printf("%d->",p->data);
printf("NULL");
}
}
}//end of switch-case
}while(op!=6); //end of Do-while loop
getch();
}//end of main function
International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 30
International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 31
ABOUT US
International Institute of Information Technology (I²IT)
P-14, Rajiv Gandhi Infotech Park, Phase – 1, Hinjawadi, Pune – 411057, India
International Institute of Information Technology (I²IT) was established by Late Shri. P. P. Chhabria,
Founder Chairman of Finolex Group of Industries, a well-known philanthropist and former
President of Mahratta Chamber of Commerce, Industries and Agriculture (MCCIA).
I²IT aspires to be an academic leader recognized for innovation, quality teaching and research,
holding high moral values and a forward thinking institution that explores creative approaches
for the future.
 Phone: +91 20 2293 3441 / 2 / 3
Toll Free Line:1800-233-4499
Fax: +91 20 2293 4191
 Email: info@isquareit.edu.in
 Web: www.isquareit.edu.in
32

More Related Content

What's hot

Graph in data structure
Graph in data structureGraph in data structure
Graph in data structureAbrish06
 
arrays and pointers
arrays and pointersarrays and pointers
arrays and pointersSamiksha Pun
 
structure and union
structure and unionstructure and union
structure and unionstudent
 
Sparse matrix and its representation data structure
Sparse matrix and its representation data structureSparse matrix and its representation data structure
Sparse matrix and its representation data structureVardhil Patel
 
Selection sort
Selection sortSelection sort
Selection sortJay Patel
 
Queue Implementation Using Array & Linked List
Queue Implementation Using Array & Linked ListQueue Implementation Using Array & Linked List
Queue Implementation Using Array & Linked ListPTCL
 
Row major and column major in 2 d
Row major and column major in 2 dRow major and column major in 2 d
Row major and column major in 2 dnikhilarora2211
 
Basic array in c programming
Basic array in c programmingBasic array in c programming
Basic array in c programmingSajid Hasan
 
Decoders-Digital Electronics
Decoders-Digital ElectronicsDecoders-Digital Electronics
Decoders-Digital ElectronicsPaurav Shah
 
Topological Sorting
Topological SortingTopological Sorting
Topological SortingShahDhruv21
 
Input and output in C++
Input and output in C++Input and output in C++
Input and output in C++Nilesh Dalvi
 

What's hot (20)

Function in C program
Function in C programFunction in C program
Function in C program
 
Array ppt
Array pptArray ppt
Array ppt
 
Graph in data structure
Graph in data structureGraph in data structure
Graph in data structure
 
Linked list
Linked listLinked list
Linked list
 
arrays and pointers
arrays and pointersarrays and pointers
arrays and pointers
 
Presentation on pointer.
Presentation on pointer.Presentation on pointer.
Presentation on pointer.
 
structure and union
structure and unionstructure and union
structure and union
 
Sparse matrix and its representation data structure
Sparse matrix and its representation data structureSparse matrix and its representation data structure
Sparse matrix and its representation data structure
 
Selection sort
Selection sortSelection sort
Selection sort
 
Queue Implementation Using Array & Linked List
Queue Implementation Using Array & Linked ListQueue Implementation Using Array & Linked List
Queue Implementation Using Array & Linked List
 
Queues
QueuesQueues
Queues
 
Tree - Data Structure
Tree - Data StructureTree - Data Structure
Tree - Data Structure
 
Arrays in c
Arrays in cArrays in c
Arrays in c
 
Pointer to function 1
Pointer to function 1Pointer to function 1
Pointer to function 1
 
Row major and column major in 2 d
Row major and column major in 2 dRow major and column major in 2 d
Row major and column major in 2 d
 
Basic array in c programming
Basic array in c programmingBasic array in c programming
Basic array in c programming
 
Decoders-Digital Electronics
Decoders-Digital ElectronicsDecoders-Digital Electronics
Decoders-Digital Electronics
 
Topological Sorting
Topological SortingTopological Sorting
Topological Sorting
 
Stacks
StacksStacks
Stacks
 
Input and output in C++
Input and output in C++Input and output in C++
Input and output in C++
 

Similar to Singly Linked List & Data Structure

Singly linked list.pptx
Singly linked list.pptxSingly linked list.pptx
Singly linked list.pptxSanthiya S
 
Assignement of c++
Assignement of c++Assignement of c++
Assignement of c++Syed Umair
 
double link list in data structure
double link list in data structuredouble link list in data structure
double link list in data structureASJADALi21
 
Singly linked list program in data structure - Vtech
Singly linked list program in data structure - VtechSingly linked list program in data structure - Vtech
Singly linked list program in data structure - VtechVtech Academy of Computers
 
Investigatory Project for Computer Science
Investigatory Project for Computer Science Investigatory Project for Computer Science
Investigatory Project for Computer Science Sonali Sinha
 
Program of sorting using shell sort #include stdio.h #de.pdf
 Program of sorting using shell sort  #include stdio.h #de.pdf Program of sorting using shell sort  #include stdio.h #de.pdf
Program of sorting using shell sort #include stdio.h #de.pdfanujmkt
 
Dataiku - Paris JUG 2013 - Hadoop is a batch
Dataiku - Paris JUG 2013 - Hadoop is a batch Dataiku - Paris JUG 2013 - Hadoop is a batch
Dataiku - Paris JUG 2013 - Hadoop is a batch Dataiku
 

Similar to Singly Linked List & Data Structure (20)

Addition of Two Polynomials
Addition of Two PolynomialsAddition of Two Polynomials
Addition of Two Polynomials
 
Importance of Theory of Computations
Importance of Theory of ComputationsImportance of Theory of Computations
Importance of Theory of Computations
 
Strings in Python
Strings in PythonStrings in Python
Strings in Python
 
What Is Cascading Style Sheet?
What Is Cascading Style Sheet?What Is Cascading Style Sheet?
What Is Cascading Style Sheet?
 
Engineering Mathematics & Probability Distributions
Engineering Mathematics & Probability DistributionsEngineering Mathematics & Probability Distributions
Engineering Mathematics & Probability Distributions
 
Euler’s Theorem Homogeneous Function Of Two Variables
Euler’s Theorem Homogeneous Function Of  Two VariablesEuler’s Theorem Homogeneous Function Of  Two Variables
Euler’s Theorem Homogeneous Function Of Two Variables
 
Functions in Python
Functions in PythonFunctions in Python
Functions in Python
 
Red Black Tree Insertion & Deletion
Red Black Tree Insertion & DeletionRed Black Tree Insertion & Deletion
Red Black Tree Insertion & Deletion
 
Singly linked list.pptx
Singly linked list.pptxSingly linked list.pptx
Singly linked list.pptx
 
What are the real differences between a wireframe, storyboard and a prototype?
What are the real differences between a wireframe, storyboard and a prototype?What are the real differences between a wireframe, storyboard and a prototype?
What are the real differences between a wireframe, storyboard and a prototype?
 
Assignement of c++
Assignement of c++Assignement of c++
Assignement of c++
 
Engineering Mathematics | Maxima and Minima
Engineering Mathematics | Maxima and MinimaEngineering Mathematics | Maxima and Minima
Engineering Mathematics | Maxima and Minima
 
double link list in data structure
double link list in data structuredouble link list in data structure
double link list in data structure
 
Introduction To Assembly Language Programming
Introduction To Assembly Language ProgrammingIntroduction To Assembly Language Programming
Introduction To Assembly Language Programming
 
Red Black Tree (and Examples)
Red Black Tree (and Examples)Red Black Tree (and Examples)
Red Black Tree (and Examples)
 
Singly linked list program in data structure - Vtech
Singly linked list program in data structure - VtechSingly linked list program in data structure - Vtech
Singly linked list program in data structure - Vtech
 
Systems Programming & Operating Systems - Overview of LEX-and-YACC
Systems Programming & Operating Systems - Overview of LEX-and-YACCSystems Programming & Operating Systems - Overview of LEX-and-YACC
Systems Programming & Operating Systems - Overview of LEX-and-YACC
 
Investigatory Project for Computer Science
Investigatory Project for Computer Science Investigatory Project for Computer Science
Investigatory Project for Computer Science
 
Program of sorting using shell sort #include stdio.h #de.pdf
 Program of sorting using shell sort  #include stdio.h #de.pdf Program of sorting using shell sort  #include stdio.h #de.pdf
Program of sorting using shell sort #include stdio.h #de.pdf
 
Dataiku - Paris JUG 2013 - Hadoop is a batch
Dataiku - Paris JUG 2013 - Hadoop is a batch Dataiku - Paris JUG 2013 - Hadoop is a batch
Dataiku - Paris JUG 2013 - Hadoop is a batch
 

More from International Institute of Information Technology (I²IT)

More from International Institute of Information Technology (I²IT) (20)

Minimization of DFA
Minimization of DFAMinimization of DFA
Minimization of DFA
 
Understanding Natural Language Processing
Understanding Natural Language ProcessingUnderstanding Natural Language Processing
Understanding Natural Language Processing
 
What Is Smart Computing?
What Is Smart Computing?What Is Smart Computing?
What Is Smart Computing?
 
Professional Ethics & Etiquette: What Are They & How Do I Get Them?
Professional Ethics & Etiquette: What Are They & How Do I Get Them?Professional Ethics & Etiquette: What Are They & How Do I Get Them?
Professional Ethics & Etiquette: What Are They & How Do I Get Them?
 
Writing Skills: Importance of Writing Skills
Writing Skills: Importance of Writing SkillsWriting Skills: Importance of Writing Skills
Writing Skills: Importance of Writing Skills
 
Professional Communication | Introducing Oneself
Professional Communication | Introducing Oneself Professional Communication | Introducing Oneself
Professional Communication | Introducing Oneself
 
Servlet: A Server-side Technology
Servlet: A Server-side TechnologyServlet: A Server-side Technology
Servlet: A Server-side Technology
 
What Is Jenkins? Features and How It Works
What Is Jenkins? Features and How It WorksWhat Is Jenkins? Features and How It Works
What Is Jenkins? Features and How It Works
 
Cloud Computing
Cloud ComputingCloud Computing
Cloud Computing
 
Hypothesis-Testing
Hypothesis-TestingHypothesis-Testing
Hypothesis-Testing
 
Data Science, Big Data, Data Analytics
Data Science, Big Data, Data AnalyticsData Science, Big Data, Data Analytics
Data Science, Big Data, Data Analytics
 
Types of Artificial Intelligence
Types of Artificial Intelligence Types of Artificial Intelligence
Types of Artificial Intelligence
 
Difference Between AI(Artificial Intelligence), ML(Machine Learning), DL (Dee...
Difference Between AI(Artificial Intelligence), ML(Machine Learning), DL (Dee...Difference Between AI(Artificial Intelligence), ML(Machine Learning), DL (Dee...
Difference Between AI(Artificial Intelligence), ML(Machine Learning), DL (Dee...
 
Sentiment Analysis in Machine Learning
Sentiment Analysis in  Machine LearningSentiment Analysis in  Machine Learning
Sentiment Analysis in Machine Learning
 
What Is Cloud Computing?
What Is Cloud Computing?What Is Cloud Computing?
What Is Cloud Computing?
 
Introduction To Design Pattern
Introduction To Design PatternIntroduction To Design Pattern
Introduction To Design Pattern
 
Java as Object Oriented Programming Language
Java as Object Oriented Programming LanguageJava as Object Oriented Programming Language
Java as Object Oriented Programming Language
 
What Is High Performance-Computing?
What Is High Performance-Computing?What Is High Performance-Computing?
What Is High Performance-Computing?
 
Data Visualization - How to connect Microsoft Forms to Power BI
Data Visualization - How to connect Microsoft Forms to Power BIData Visualization - How to connect Microsoft Forms to Power BI
Data Visualization - How to connect Microsoft Forms to Power BI
 
AVL Tree Explained
AVL Tree ExplainedAVL Tree Explained
AVL Tree Explained
 

Recently uploaded

ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 

Recently uploaded (20)

ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 

Singly Linked List & Data Structure

  • 1. International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 1 -Varsha Degaonkar www.isquareit.edu.in
  • 2. International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 2
  • 3. International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 3 INTRODUCTION SINGLY LINKED LIST (SLL): • Singly Linked List is collection of data elements. • Each element represents a node in SLL. • Each node consists of one or more data fields and one address field which stores the address of next node. • Operations in SLL: Creation Insertion Display
  • 4. SINGLY LINKED LIST #include<stdio.h> #include<conio.h> #include<stdlib.h> typedef struct sll { int data; struct sll *next; }sll; International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 4 Structure definition Creation of user defined data type.
  • 5. SINGLY LINKED LIST #include<stdio.h> #include<conio.h> #include<stdlib.h> typedef struct sll { int data; struct sll *next; }sll; void main() { int op; sll *head=NULL; clrscr(); International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 5 Pointer variable declaration of the Structure and assigning value to it data *next Node of SLL:
  • 6. sll *create(sll *); /*function declaration*/ sll *insert(sll *); /*function declaration*/ void disp(sll *); /*function declaration*/ do // menu driven program { printf("1)Createn2)Insertn3) Displayn4)Exit"); printf("nEnter the option: "); scanf("%d",&op); switch(op) { International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 6
  • 7. case 1: head=create(head); /*Function Call*/ break; International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 7 sll *create(sll *head) { sll *p,*nw; char ans; do { nw=(sll*)malloc(sizeof(sll));nw=500
  • 8. case 1: head=create(head); /*Function Call*/ break; International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 8 sll *create(sll *head) { sll *p,*nw; char ans; do { nw=(sll*)malloc(sizeof(sll)); nw->next=NULL; NULL nw=500
  • 9. case 1: head=create(head); /*Function Call*/ break; International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 9 sll *create(sll *head) { sll *p,*nw; char ans; do { nw=(sll*)malloc(sizeof(sll)); nw->next=NULL; printf("nEnter the data:"); scanf("%d",&(nw->data)); NULL10 nw=500
  • 10. case 1: head=create(head); /*Function Call*/ break; International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 10 sll *create(sll *head) { sll *p,*nw; char ans; do { nw=(sll*)malloc(sizeof(sll)); nw->next=NULL; printf("nEnter the data:"); scanf("%d",&(nw->data)); if(head==NULL) NULL10 nw=500
  • 11. case 1: head=create(head); /*Function Call*/ break; International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 11 sll *create(sll *head) { sll *p,*nw; char ans; do { nw=(sll*)malloc(sizeof(sll)); nw->next=NULL; printf("nEnter the data:"); scanf("%d",&(nw->data)); if(head==NULL) p=head=nw; NULL10 p=head=nw=500
  • 12. case 1: head=create(head); /*Function Call*/ break; International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 12 sll *create(sll *head) { sll *p,*nw; char ans; do { nw=(sll*)malloc(sizeof(sll)); nw->next=NULL; printf("nEnter the data:"); scanf("%d",&(nw->data)); if(head==NULL) p=head=nw; else NULL10 p =head=500 NULL20 nw=600
  • 13. case 1: head=create(head); /*Function Call*/ break; International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 13 sll *create(sll *head) { sll *p,*nw; char ans; do { nw=(sll*)malloc(sizeof(sll)); nw->next=NULL; printf("nEnter the data:"); scanf("%d",&(nw->data)); if(head==NULL) p=head=nw; else { p->next=nw; 60010 p=head=500 NULL20 nw=600
  • 14. case 1: head=create(head); /*Function Call*/ break; International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 14 sll *create(sll *head) { sll *p,*nw; char ans; do { nw=(sll*)malloc(sizeof(sll)); nw->next=NULL; printf("nEnter the data:"); scanf("%d",&(nw->data)); if(head==NULL) p=head=nw; else { p->next=nw; p=nw; } 60010 p=head=500 NULL20 p=nw=600
  • 15. case 1: head=create(head); /*Function Call*/ break; International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 15 sll *create(sll *head) { sll *p,*nw; char ans; do { nw=(sll*)malloc(sizeof(sll)); nw->next=NULL; printf("nEnter the data:"); scanf("%d",&(nw->data)); if(head==NULL) p=head=nw; else { p->next=nw; p=nw; } printf("nt Do you want to insert node(Y/N)"); flushall(); scanf("%c",&ans); }while(ans=='y'||ans=='Y'); return(head); } 60010 head=500 NULL20 p=600 NULL30 nw=700
  • 16. case 1: head=create(head); /*Function Call*/ break; International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 16 sll *create(sll *head) { sll *p,*nw; char ans; do { nw=(sll*)malloc(sizeof(sll)); nw->next=NULL; printf("nEnter the data:"); scanf("%d",&(nw->data)); if(head==NULL) p=head=nw; else { p->next=nw; p=nw; } printf("nt Do you want to insert node(Y/N)"); flushall(); scanf("%c",&ans); }while(ans=='y'||ans=='Y'); return(head); } 60010 head=500 70020 p=600 NULL30 nw=700
  • 17. case 1: head=create(head); /*Function Call*/ break; International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 17 sll *create(sll *head) { sll *p,*nw; char ans; do { nw=(sll*)malloc(sizeof(sll)); nw->next=NULL; printf("nEnter the data:"); scanf("%d",&(nw->data)); if(head==NULL) p=head=nw; else { p->next=nw; p=nw; } printf("nt Do you want to insert node(Y/N)"); flushall(); scanf("%c",&ans); }while(ans=='y'||ans=='Y'); return(head); } 60010 head=500 70020 p=600 NULL30 p=nw=700
  • 18. case 2: head= insert(head); break; International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 18 sll *insert(sll *head) { sll *p,*q; int loc,i; printf("nEnter the location:"); scanf("%d",&loc); //enter location for node insertion p=(sll*)malloc(sizeof(sll)); //create new node printf("nenter a data:"); //enter data in node scanf("%d",&(p->data)); if(loc==1) //Insertion as head node i.e. if position is 1 { p->next=head; head=p; return(head); } 60010 head=500 70020 600 NULL30 700
  • 19. case 2: head= insert(head); break; International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 19 sll *insert(sll *head) { sll *p,*q; int loc,i; printf("nEnter the location:"); scanf("%d",&loc); //enter location for node insertion p=(sll*)malloc(sizeof(sll)); //create new node printf("nenter a data:"); //enter data in node scanf("%d",&(p->data)); if(loc==1) //Insertion as head node i.e. if position is 1 { p->next=head; head=p; return(head); } 60010 head=500 70020 600 NULL30 700 5 P=400
  • 20. case 2: head= insert(head); break; International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 20 sll *insert(sll *head) { sll *p,*q; int loc,i; printf("nEnter the location:"); scanf("%d",&loc); //enter location for node insertion p=(sll*)malloc(sizeof(sll)); //create new node printf("nenter a data:"); //enter data in node scanf("%d",&(p->data)); if(loc==1) //Insertion as head node i.e. if position is 1 { p->next=head; head=p; return(head); } 60010 head=500 70020 600 NULL30 700 5005 p=head=400
  • 21. case 2: head= insert(head); break; International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 21 else // if insertion is at other position than head node { i=1;q=head; while(i<loc-1) { q=q->next; i++; } p->next=q->next; q->next=p; } disp(head); return(head); } 60010 q=head=500 70020 600 NULL30 700 NULL25 p=750
  • 22. case 2: head= insert(head); break; International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 22 else // if insertion is at other position than head node { i=1;q=head; while(i<loc-1) { q=q->next; i++; } p->next=q->next; q->next=p; } disp(head); return(head); } 60010 q=head=500 70020 q=600 NULL30 700 NULL25 p=750
  • 23. case 2: head= insert(head); break; International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 23 else // if insertion is at other position than head node { i=1;q=head; while(i<loc-1) { q=q->next; i++; } p->next=q->next; q->next=p; } disp(head); return(head); } 60010 q=head=500 70020 q=600 NULL30 700 70025 p=750
  • 24. case 2: head= insert(head); break; International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 24 else // if insertion is at other position than head node { i=1;q=head; while(i<loc-1) { q=q->next; i++; } p->next=q->next; q->next=p; } disp(head); return(head); } 60010 q=head=500 75020 q=600 NULL30 700 70025 p=750
  • 25. case 3: head= disp(head); break; International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 25 void disp(sll *head) { sll *p; if(head==NULL)//if linked list is not created printf("nEmpty Linked List"); else { printf("nn Created SLL:nn "); for(p=head;p!=NULL;p=p->next) printf("%d->",p->data); printf("NULL"); } } 60010 head=500 70020 600 NULL30 700
  • 26. case 3: head= disp(head); break; International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 26 void disp(sll *head) { sll *p; if(head==NULL)//if linked list is not created printf("nEmpty Linked List"); else { printf("nn Created SLL:nn "); for(p=head;p!=NULL;p=p->next) printf("%d->",p->data); printf("NULL"); } } 60010 p=head=500 70020 600 10-> NULL30 700
  • 27. case 3: head= disp(head); break; International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 27 60010 p=head=500 70020 p=600 10->20-> NULL30 700 void disp(sll *head) { sll *p; if(head==NULL)//if linked list is not created printf("nEmpty Linked List"); else { printf("nn Created SLL:nn "); for(p=head;p!=NULL;p=p->next) printf("%d->",p->data); printf("NULL"); } }
  • 28. case 3: head= disp(head); break; International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 28 60010 p=head=500 70020 p=600 10->20->30-> NULL30 p=700 void disp(sll *head) { sll *p; if(head==NULL)//if linked list is not created printf("nEmpty Linked List"); else { printf("nn Created SLL:nn "); for(p=head;p!=NULL;p=p->next) printf("%d->",p->data); printf("NULL"); } }
  • 29. case 3: head= disp(head); break; International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 29 60010 p=head=500 70020 p=600 10->20->30-> NULL NULL30 p=700 p=NULL void disp(sll *head) { sll *p; if(head==NULL)//if linked list is not created printf("nEmpty Linked List"); else { printf("nn Created SLL:nn "); for(p=head;p!=NULL;p=p->next) printf("%d->",p->data); printf("NULL"); } }
  • 30. }//end of switch-case }while(op!=6); //end of Do-while loop getch(); }//end of main function International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 30
  • 31. International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Toll Free - 1800 233 4499 Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in 31
  • 32. ABOUT US International Institute of Information Technology (I²IT) P-14, Rajiv Gandhi Infotech Park, Phase – 1, Hinjawadi, Pune – 411057, India International Institute of Information Technology (I²IT) was established by Late Shri. P. P. Chhabria, Founder Chairman of Finolex Group of Industries, a well-known philanthropist and former President of Mahratta Chamber of Commerce, Industries and Agriculture (MCCIA). I²IT aspires to be an academic leader recognized for innovation, quality teaching and research, holding high moral values and a forward thinking institution that explores creative approaches for the future.  Phone: +91 20 2293 3441 / 2 / 3 Toll Free Line:1800-233-4499 Fax: +91 20 2293 4191  Email: info@isquareit.edu.in  Web: www.isquareit.edu.in 32