We will discuss the doubly linked list in our next tutorial. In this LinkedList tutorial, we will deal mostly with the singly linked list. The previous pointer of the first node points to null while the next pointer of the last node points to null. The previous address of the first element in the LinkedList will be set to Null while the next pointer of the Last element in the LinkedList is set to Null.Īs shown in the above representation, each node in the doubly linked list has pointers to its previous and next node (thus represented without arrows). Address or reference or pointer to the next element in the LinkedList.Address or reference or pointer to the previous element in the LinkedList.There is another version known as “ Doubly Linked List” whose each node has three parts: The above diagram represents a “ Singly-linked List” that stores the address of only the next node in the LinkedList. As shown in the figure above, the address part of the last node in the LinkedList is set to ‘Null’ indicating the end of the LinkedList. The last node in the LinkedList is the tail. The “Head” of the LinkedList is a pointer that contains the address of the first element in the LinkedList. This arrangement is necessary as the data in LinkedList is stored in non-contiguous locations, unlike Arrays. Each node has two parts, the first part stores the data and the second part has a reference or pointer or address of the next node in the LinkedList. Given below is the general Layout of LinkedList:Īs shown in the above representation of LinkedList, each item in the LinkedList is the “Node”.
0 Comments
Leave a Reply. |