File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed
03_data_structures/02_linked_list/02_linked_list/02_doubly_linked_list Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -86,4 +86,29 @@ class Node:
86
86
* Points to the ** previous node** in the list (the one to the left in diagrams).
87
87
* A brand-new node has ** no predecessor** , so ` prev=None ` .
88
88
89
- ---
89
+ ---
90
+
91
+ ---
92
+
93
+ # ➕ ** Doubly Linked List class**
94
+
95
+ In a ** doubly linked list** , each node knows both its ** next** and ** previous** neighbor. To append (add to the end), we update:
96
+
97
+ 1 . The current ** tail** ’s ` .next ` → new node
98
+ 2 . The new node’s ` .prev ` → old tail
99
+ 3 . The list’s ** tail** pointer → new node
100
+ 4 . Increase the ** count**
101
+
102
+ ---
103
+
104
+ ## 📜 Code for ` DoublyLinkedList class `
105
+
106
+ ``` python
107
+ class DoublyLinkedList :
108
+ def __init__ (self ):
109
+ self .head = None # First node
110
+ self .tail = None # Last node
111
+ self .count = 0 # Number of nodes
112
+
113
+ ```
114
+ ---
You can’t perform that action at this time.
0 commit comments