




































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
These are the slides related to Data structure and Algorithms. A Detailed note on Link list .
Typology: Exams
1 / 44
This page cannot be seen from the preview
Don't miss anything!





































(^) A linked list is a linear data structure. (^) Nodes make up linked lists. (^) Nodes are structures made up of data and a pointer to another node. (^) Usually the pointer is called next.
Types of lists There are two basic types of linked list
Singly Linked List (^) Each node has only one link part (^) Each link part contains the address of the next node in the list (^) Link part of the last node contains NULL value which signifies the end of the node
Basic Operations on a list
Creating a node / / A simple node of a linked list struct node{ int data; nodenext; }start; start=NULL ; //start points at the first node initialised to NULL at beginning
To be called from main() as:- void main() { node* ptr; int data; cin>>data; ptr=create (data); }
Inserting the node in a SLL
//if the list is empty void insert_beg(node* p) { node* temp; if(start==NULL) { start=p; cout<<”\nNode inserted successfully at the beginning”; } else { } temp=start; start=p; p-
next=tem p; //making new node }
void insert_end(node* p) { node *q=start; if(start==NULL) { start= p; cout< <”
nNode insert ed succes sfully at the end…!
Inserting after an element
void insert_after(int c,node* p) { node* q; q=start; for( int i=1; i<c; i+ +) { q= q-
li nk;
i
Deleting a node in SLL