The only difference between the singly linked list and a circular linked list is that the last node does not point to any node in a singly linked list, so its link part contains a NULL value. To know more about doubly linked list, click on the link given below:Ī circular linked list is a variation of a singly linked list. The type of both the pointers, i.e., next and prev is struct node as both the pointers are storing the address of the node of the struct node type. The next pointer variable holds the address of the next node, and the prev pointer holds the address of the previous node. In the above representation, we have defined a user-defined structure named a node with three members, one is data of integer type, and the other two are the pointers, i.e., next and prev of the node type. Representation of the node in a doubly linked list The initial node in the doubly linked list has the NULL value in the address part, which provides the address of the previous node. The representation of these nodes in a doubly-linked list is shown below:Īs we can observe in the above figure, the node in a doubly-linked list has two address parts one part stores the address of the next while the other part of the node stores the previous node's address. Suppose we have three nodes, and the address of these nodes are 100, 200 and 300, respectively. In other words, a doubly linked list is a list that has three parts in a single node, includes one data part, a pointer to its previous node, and a pointer to the next node. We can define the doubly linked list as a linear data structure with three parts: the data part and the other two address part. To know more about a singly linked list, click on the link given below:Īs the name suggests, the doubly linked list contains two pointers. In the above representation, we have defined a user-defined structure named a node containing two members, the first one is data of integer type, and the other one is the pointer (next) of the node type. Representation of the node in a singly linked list In this list, only forward traversal is possible we cannot traverse in the backward direction as it has only one link in the list. The linked list, which is shown in the above diagram, is known as a singly linked list as it contains only a single link. The pointer that holds the address of the initial node is known as a head pointer. The first node contains the address of the next node, i.e., 200, the second node contains the address of the last node, i.e., 300, and the third node contains the NULL value in its address part as it does not point to any node. We can observe in the above figure that there are three different nodes having address 100, 200 and 300 respectively. The representation of three nodes as a linked list is shown in the below figure: Suppose we have three nodes, and the addresses of these three nodes are 100, 200 and 300 respectively. The address part in a node is also known as a pointer. The singly linked list is a data structure that contains two parts, i.e., one is the data part, and the other one is the address part, which contains the address of the next or the successor node. If we are talking about the linked list, it means it is a singly linked list. It is the commonly used linked list in programs. The following are the types of linked list: So, to know about the linked list, click on the link given below: Types of Linked list Before knowing about the types of a linked list, we should know what is linked list.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |