Académique Documents
Professionnel Documents
Culture Documents
SUBMITTED TO :BY :-
SUBMITTED
Amit
DYNAMIC
MEMORY
ALLOCATION
DYANMIC MEMORY
ALLOCATION
COMPARISON
BETWEEN SINGLE
AND DOUBLE
LINKEDLIST
In a standard linked list,
we can only traverse the list in one
direction. It may be useful however,
to be able to go both forwards and
backwards when traversing a linked
list. In order to allow this, we need
each Node to contain not one, but
two references to Nodes - one to the
next Node in the list and one to the
previous Node in the list.
header=NULL;
ptr=new node;
ptr->next=NULL;
ptr->prev=NULL;
header=ptr;
} where prev is reference for address of previous node.
HEADE
R
As clear from the fig. that in a singly linked list, each
node contains the address of next node.
HEADE
R
Deletion
ALSO..
1. At BEGINNING
2. At END
3. After any element
INSERTION AT BEGINNING
IN SINGLY LINKED LIST
In this insertion the new node is given the address of
first node taking it from header and header is
pointed
to the new node.
HEADE
R
New
Nod
e
HEADE
R
Ne
w
No
INSERTION AT END
IN SINGLY LINKED LIST
In this insertion, the new node is given NULL in its next
part and address of the new node is stored in the last
node before insertion. We have to reach the
Ne last node
by traversing.
w
HEADE
R
No
de
No
de
HEADE
R
Inputted
item
New
node
New
Nod
e
THANKS