Singly Linked List
Singly Linked List
Linked List
1003
1004 ////////// Enough memory locations are available to store the list but
1005 contiguous 6 bytes are not available. So memory allocation will
1006 be failed if we want to use the array.
1007
1010
1011
1012
Addresses Value
1000
25 Same thing we can represent as follows too:
1001
1002
1005
25 1005 67 1010 89 NULL
1003
1006
67
1007
1008 1010
1009 //////////
1010
1011
89
1012
NULL
1013
Address of
this node is Head pointer will keep the address
suppose of first node of the linked list.
1000
struct node
Data Pointer to next node
{
int data;
struct node * next;
} *head = NULL;
Case 2: insert node at end in the existing linked list with nodes head = 1500 1000
15 NULL
i. Create new node: new1= 3000
iii. We need to change the next part of node with address 1000.
1000->next = new1(3000)
How can we get the address of last node?
- Last node’s feature is : its next field is NULL. That we can use to find the address of last node.