Self referential structure is a structure having pointer/s to structure of same type as a member.
Consider the node structure used for a linked list
Linked list can be shown as
Consider the node structure used for a linked list
struct node
{
...
struct node* next;
};
Node structure has a pointer to node structure (next) as its member.Linked list can be shown as
__________ ___________ ___________
| | | | | | | | |
head---->| | ---|------->| | --|---- -- -- -- ----->| | --|----->NULL
|____|____| |____|_____| |____|____|
data next
Node 1 Node 2 Node n
No comments:
Post a Comment