You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: data_structures/linked_list/doubly_linked_list.py
+22-21
Original file line number
Diff line number
Diff line change
@@ -2,49 +2,50 @@
2
2
- A linked list is similar to an array, it holds values. However, links in a linked list do not have indexes.
3
3
- This is an example of a double ended, doubly linked list.
4
4
- Each link references the next link and the previous one.
5
-
'''
5
+
- A Doubly Linked List (DLL) contains an extra pointer, typically called previous pointer, together with next pointer and data which are there in singly linked list.
6
+
- Advantages over SLL - IT can be traversed in both forward and backward direction.,Delete operation is more efficent'''
6
7
from __future__ importprint_function
7
8
8
9
9
-
classLinkedList:
10
+
classLinkedList:#making main class named linked list
10
11
def__init__(self):
11
12
self.head=None
12
13
self.tail=None
13
14
14
15
definsertHead(self, x):
15
-
newLink=Link(x) #Create a new link with a value attached to it
16
-
if(self.isEmpty() ==True): #Set the first element added to be the tail
16
+
newLink=Link(x) #Create a new link with a value attached to it
17
+
if(self.isEmpty() ==True): #Set the first element added to be the tail
0 commit comments