Skip to content

Added abstract methods for LinkedList base class #223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions pydatastructs/linear_data_structures/linked_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,66 @@ def __str__(self):
break
return str(elements)

def insert_after(self, prev_node, key, data=None):
"""
Inserts a new node after the prev_node.

Parameters
==========

prev_node: LinkedListNode
The node after which the
new node is to be inserted.

data
Any valid data to be stored in the node.
"""
raise NotImplementedError('This is an abstract method')

def insert_at(self, index, key, data=None):
"""
Inserts a new node at the input index.

Parameters
==========

index: int
An integer satisfying python indexing properties.

data
Any valid data to be stored in the node.
"""
raise NotImplementedError('This is an abstract method')

def extract(self, index):
"""
Extracts the node at the index of the list.

Parameters
==========

index: int
An integer satisfying python indexing properties.

Returns
=======

current_node: LinkedListNode
The node at index i.
"""
raise NotImplementedError('This is an abstract method')

def __getitem__(self, index):
"""
Returns
=======

current_node: LinkedListNode
The node at given index.
"""
raise NotImplementedError('This is an abstract method')


class DoublyLinkedList(LinkedList):
"""
Represents Doubly Linked List
Expand Down