@@ -43,6 +43,66 @@ def __str__(self):
43
43
break
44
44
return str (elements )
45
45
46
+ def insert_after (self , prev_node , key , data = None ):
47
+ """
48
+ Inserts a new node after the prev_node.
49
+
50
+ Parameters
51
+ ==========
52
+
53
+ prev_node: LinkedListNode
54
+ The node after which the
55
+ new node is to be inserted.
56
+
57
+ data
58
+ Any valid data to be stored in the node.
59
+ """
60
+ raise NotImplementedError ('This is an abstract method' )
61
+
62
+ def insert_at (self , index , key , data = None ):
63
+ """
64
+ Inserts a new node at the input index.
65
+
66
+ Parameters
67
+ ==========
68
+
69
+ index: int
70
+ An integer satisfying python indexing properties.
71
+
72
+ data
73
+ Any valid data to be stored in the node.
74
+ """
75
+ raise NotImplementedError ('This is an abstract method' )
76
+
77
+ def extract (self , index ):
78
+ """
79
+ Extracts the node at the index of the list.
80
+
81
+ Parameters
82
+ ==========
83
+
84
+ index: int
85
+ An integer satisfying python indexing properties.
86
+
87
+ Returns
88
+ =======
89
+
90
+ current_node: LinkedListNode
91
+ The node at index i.
92
+ """
93
+ raise NotImplementedError ('This is an abstract method' )
94
+
95
+ def __getitem__ (self , index ):
96
+ """
97
+ Returns
98
+ =======
99
+
100
+ current_node: LinkedListNode
101
+ The node at given index.
102
+ """
103
+ raise NotImplementedError ('This is an abstract method' )
104
+
105
+
46
106
class DoublyLinkedList (LinkedList ):
47
107
"""
48
108
Represents Doubly Linked List
0 commit comments