11/23/2023 0 Comments Doubly linked list![]() ![]() Removing the node from beginning of the list SNĪdding the node into the linked list at beginning.Īdding the node into the linked list to the end.Īdding the node into the linked list after the specified node. We can traverse the list in this way until we find any node containing null or -1 in its next part.Īll the remaining operations regarding doubly linked list are described in the following table. The next node of the list resides at address 4 therefore the first node contains 4 in its next pointer. Since this is the first element being added to the list therefore the prev of the list contains null. The head pointer points to the starting address 1. In the following image, the first element of the list that is i.e. However, we can easily manipulate the elements of the list since the list maintains pointers in both the directions (forward and backward). Generally, doubly linked list consumes more space for every node and therefore, causes more expansive basic operations such as insertion and deletion. Memory Representation of a doubly linked list is shown in the following image. Memory Representation of a doubly linked list Due to the fact that, each node of the list contains the address of its previous node, we can find all the details about the previous node as well by using the previous address stored inside the previous part of each node. However, doubly linked list overcome this limitation of singly linked list. In a singly linked list, we could traverse only in one direction, because each node contains address of the next node and it doesn't have any record of its previous nodes. The prev part of the first node and the next part of the last node will always contain null indicating end in each direction.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |