Previous | Home | Next |
What is a linked list ?
A Linked List is a special kind of list in which the each element of the list is linked to another element of the list. In a linked list each element of the linked list knows the address of the next element via a pointer.
In general, a linked list element or node consists of two fields , one field is called num field in which the data value which has to be inserted is contained and second field is called next, which is a pointer which usually contains the address of the next element in the list.
Thus, a linked list node can be showed graphically as :
Singly Linked List: In SinglyLinked List the element or node of the list contains two fields viz. num field and the next pointer field. This can be shown as :
In a singly linked list the last node of the list will always point to the NULL.
Circular Linked List: In Circular Linked List, the list element are arranged in the same way as in the singly linked list having only one difference that the last element of the circular linked list always point to the first node of the list i.e. it means that last node does not point to NULL. In other words, we can say that the circular list is a list which does not have an end.
Doubly Linked List: In Doubly Linked List the node of the list generally consists of the the three fields i.e. one num field which contains the data value, and two pointer fields viz. next pointer and previous pointer. As we know next pointer contains the address of the next element in the list, and previous pointer would be containing the address of the previous node in the list. The double linked list can be shown graphically as:
- Dynamic Memory Allocation : While using the linked lists we can increase or decrease the size of the list as per our requirement, as the memory is allocated dynamically, so we can say that is it is a efficient way of utilizing the memory and prevent memory wastage.
- Various operations like insertion, deletions, traversing, sorting are much more easier to perform than in comparison to the other data structures and in quick time as well.
Previous | Home | Next |