Skip to content

Commit ad17f04

Browse files
New DLL implementation
Fixed pre commit fails for PR Added in more test cases deleted the unwanted comments
1 parent 69180f7 commit ad17f04

File tree

1 file changed

+18
-32
lines changed

1 file changed

+18
-32
lines changed

data_structures/linked_list/doubly_linked_list.py

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -204,39 +204,25 @@ def create_linked_list():
204204
20
205205
>>> new_linked_list.get_head_data()
206206
20
207+
208+
>>> new_linked_list_2 = LinkedList()
209+
>>> for value in range(1,10):
210+
... new_linked_list_2.insert(value=value)
211+
>>> print(new_linked_list_2)
212+
1<-->2<-->3<-->4<-->5<-->6<-->7<-->8<-->9
213+
>>> print(new_linked_list_2.get_head_data())
214+
1
215+
>>> new_linked_list_2.delete_value(value=0)
216+
'Node not found'
217+
>>> print(new_linked_list_2)
218+
1<-->2<-->3<-->4<-->5<-->6<-->7<-->8<-->9
219+
>>> new_linked_list_2.insert_at_position(position=1, value=100)
220+
>>> print(new_linked_list_2)
221+
100<-->1<-->2<-->3<-->4<-->5<-->6<-->7<-->8<-->9
222+
>>> new_linked_list_2.delete_value(value=5)
223+
>>> print(new_linked_list_2)
224+
100<-->1<-->2<-->3<-->4<-->6<-->7<-->8<-->9
207225
"""
208-
linked_list = LinkedList()
209-
for i in range(10):
210-
linked_list.insert(value=i)
211-
212-
print(linked_list)
213-
# 0<-->1<-->2<-->3<-->4<-->5<-->6<-->7<-->8<-->9
214-
print(linked_list.head)
215-
# 0
216-
linked_list.delete_value(value=0)
217-
print(linked_list.head)
218-
# 1
219-
print(linked_list)
220-
# 1<-->2<-->3<-->4<-->5<-->6<-->7<-->8<-->9
221-
linked_list.insert_at_position(position=1, value=100)
222-
# 100<-->1<-->2<-->3<-->4<-->5<-->6<-->7<-->8<-->9
223-
print(linked_list)
224-
linked_list.delete_value(value=5)
225-
print(linked_list)
226-
# 100<-->1<-->2<-->3<-->4<-->6<-->7<-->8<-->9
227-
print(linked_list.is_empty())
228-
# False
229-
linked_list.insert_at_position(position=12, value=200)
230-
231-
for i in range(5):
232-
print(linked_list)
233-
linked_list.delete_value(linked_list.tail.data)
234-
# for each iterations
235-
# 100 < -->1 < -->2 < -->3 < -->4 < -->6 < -->7 < -->8 < -->9 < -->200
236-
# 100 < -->1 < -->2 < -->3 < -->4 < -->6 < -->7 < -->8 < -->9
237-
# 100 < -->1 < -->2 < -->3 < -->4 < -->6 < -->7 < -->8
238-
# 100 < -->1 < -->2 < -->3 < -->4 < -->6 < -->7
239-
# 100 < -->1 < -->2 < -->3 < -->4 < -->6
240226

241227

242228
if __name__ == '__main__':

0 commit comments

Comments
 (0)