Data structure of double linked list
What is the Doubly Linked List?
The Doubly Linked List is a variant of the Linked List, in which browsing through the buttons can be done in two ways: easy forward and backward. when compared with Single Link List. Here are some important concepts to keep in mind about the Double Link List.
Link : each link of a linked List can store a data and is called an element.
Next : each link of a linked list can contain a link to the next link and is called Next.
Prev : each link of a linked list may contain a link to previous links and is called Prev.
First and Last : a List of links containing links that link to the first link called First and to the last link called Last.
Performing List of double links
As shown above, you need to remember:
The list of double links contains a link element and is called First and Last.
Each link has a data field and a link field called Next.
Each link is linked to the next element by using Next Link.
Each link is linked to the previous element by using Prev Link.
Last Link brings a link pointing to NULL to mark the end of the Link List.
Basic activities on the Double Link List
Insert operation : add an element to the top position of the Linked List.
Delete operation : delete an element at the beginning of the Linked List.
Inserting operation at the end : add an element to the end position of the Linked List.
Activity to delete the last element: delete an element at the end of the Linked List.
The following insert operation : add an element after an element of the Linked List.
Delete operation (by key) : Delete an element from the Linked List by using the provided key.
Display the list forward : display the entire Link list in the forward direction.
Display the list to the back : display the entire Link list in the backward direction.
Insert operation in the double linked list
The following is an algorithm that illustrates the insert operation at the beginning of a double linked list.
//Chèn link tại vị trí đầu tiên void insertFirst ( int key , int data ) { //tạo một link struct node * link = ( struct node *) malloc ( sizeof ( struct node )); link -> key = key ; link -> data = data ; if ( isEmpty ()) { //Biến nó thành last link last = link ; } else { //Cập nhật prev link đầu tiên head -> prev = link ; } //Trỏ nó tới first link cũ link -> next = head ; //Trỏ first tới first link mới head = link ; }
To find out the detailed code of the double linked list in C language, please click on the chapter: Program of double link list in C.
According to Tutorialspoint
Previous article: Linked list data structure (Linked List)
Next article: Loop List List (Circular Linked List)
You should read it
- Data Link List structure (Circular Linked List)
- How to Double Space on WordPad
- How to Wire a Double Switch
- Linked list data structure (Linked List)
- Instructions for creating double exposure images in Photoshop
- How to Double Space
- Steps to fix double quotes in Word
- The To-do List is good, the Done List is very good, but the Do-Not-Do List is much better
- How to Print Double Quotes in Java
- How to check the link security embedded in the email
- How to create a double exposure effect using Snapseed
- Causes of mouse Double Click and how to fix it
Maybe you are interested
How to share text on Chrome as a link
Download link for Adobe After Effects 32bit, 64bit FULL standard free
Instructions for viewing link summary content on Chrome
How to delete links in Excel, delete hyperlinks in Excel
How to turn off Update Link notification in Excel - File content from many different sources
Close-up of a mantis shrimp's punch stronger than a bullet, killing a mud crab in the blink of an eye