Linked List |
Linked List
Data Structure
Data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently.
Classification:
Two major classification of data structure are:
- Linear data structure (Linked list, stack, queue etc)
- Non Linear data structure (tree, graph)
Linked List
Linked List is a Data structure used for storing collections of data.
Linked List has following property:
- Successive elements are connected by pointers.
- Last element point to Null (except Circuler Linked List).
- It can grow or shrink size during execution of a program.
- It can be made just as long as required.
- It does not waste memory space.
Diagrammatic Representation
Singly Linked List |
➝There are three main Linked List operations
- Insertion
- Deletion
- Traversing
Node
When we talk about storing List of Information, each information set is a node which also plays a role of connection point in the list.
Defining a node (Data Type) in Singly Linked List
struct node
{
int data;
struct node *next;
};
node |
Doubly Linked List
Doubly Linked List contains one extra pointer as compare to the node of Singly Linked List.
From any node we can traverse in both the direction.
Diagrammatic Representation
Defining a node (Data Type) in Doubly Linked List
struct node
{
int data;
struct node *prev, *next;
};
node |
Circular Linked List
Linked List in which next pointer field (link field) of the last node contain the address of the first node instead of NULL pointer is called Circular Linked List
Diagrammatic Representation
Circular Linked LIst |
Condition for underflow or List is empty:
Start = = NULL
Condition for overflow:
temp= = NULL
{Here temp is a temporary pointer variable}
Condition for only one node in CLL:
Start = = Start -> next
Only one node in CLL |
0 Comments
Please do not enter any spam link in the comment box.