X.previous points to NULL, and X.Next points to Head or to A. So as we can see, to insert an element at front, we need to change pointers of A Node.Įarlier: Head points to A and A.previous points = NULL. Now after we insert X inside this Doubly Linked List: X ⇆ A ⇆ B ⇆ C There can be 4 different ways of inserting a new Element inside a Doubly Linked List, and we will see each of these ways in detail below: Insert FirstĪ Node can be inserted as the first element in the Doubly Linked List. If we go with Arrays, those will be represented as īut this shifting of rest of the elements is not required if the inserting is to be done inside the doubly linked list. I would suggest going through the Linked List concepts before jumping ahead with Doubly Linked List.īut to summarize, say we have 3 elements, Sebuah linked list dikatakan kosong apabila isi pointer head adalah NULL. Different operations of Doubly Linked List.Īs you can guess, Doubly Linked List is an enhancement done on top of Linked List Data Structures. Di dalam sebuah linked list, ada 2 pointer yang menjadi penunjuk utama, yakni pointer HEAD yang menunjuk pada node pertama di dalam linked list itu sendiri dan pointer TAIL yang menunjuk pada node paling akhir di dalam linked list.This article tells about the working of the Doubly Linked List.Doubly Linked List is a variation of Linked list in which navigation is possible in both ways, either forward and backward easily as compared to Single Linked List.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |