linked list
linked list - linked list is a non-primitive linear data structure, it is the collection of nodes & a start pointer.
Each element (we will call it a node) of a list is contain or stores 2 items.
1. Data of the node
2. address(reference) of the node
** The last node has a reference to NULL.
** The entry point into a linked list is called the head of the list.
note:
# If the list is empty then the head is a null reference.
# If the list is empty then the head is a null reference.
# pointer have 4 bytes data always in 32 bits compiler.
# pointer independent from data type.
# pointer contain base address, its size depend upon compiler.
# pointer independent from data type.
# pointer contain base address, its size depend upon compiler.
advantages:
1. a linked list is a dynamic data structure.
2. The number of nodes in a list is not fixed and can grow and shrink on demand.
disadvantages:
1. it use more memory compare with an array.
2. it does not allow direct access to the individual elements.
there are 3 types of linked list:
1.single linked list.
2.double linked list.
3.circular linked list.
1.single linked list:
2. it does not allow direct access to the individual elements.
there are 3 types of linked list:
1.single linked list.
2.double linked list.
3.circular linked list.
1.single linked list:
2.double linked list:
it contain 3 fields: the link to the previous node, the data ,and the link to the next node
3.circular linked list:
Circular linked list is a linked list where all nodes are connected to form a circle. There is no NULL at the end. A circular linked list can be a singly circular linked list or doubly circular linked list.
3.circular linked list:
Circular linked list is a linked list where all nodes are connected to form a circle. There is no NULL at the end. A circular linked list can be a singly circular linked list or doubly circular linked list.
Nice
ReplyDelete