src.pydasa.structs.lists.ndlt#

Module to represent the Node data structure for the Linked List and Doubly Linked List in PyDASA.

Classes:

Node: Base class for creating Single Linked List Node or SLNode and Double Linked List Node or DLNode. SLNode: Implements a single linked list node with data and next node reference. DLNode: Implements a double linked list node with data, next node, and previous node references.

IMPORTANT: based on the implementations proposed by the following authors/books:

# . Algorithms, 4th Edition, Robert Sedgewick and Kevin Wayne. # . Data Structure and Algorithms in Python, M.T. Goodrich, R. Tamassia, M.H. Goldwasser.

Classes#

Node

Node base class for creating Single Linked List Node or SLNode and Double Linked List Node or DLNode. Fundamental for the Linked List and Doubly Linked List data structures.

SLNode

SLNode class for creating a Single Linked List Node. Inherits from the Node class. Fundamental for the Linked List data structure.

DLNode

DLNode class for creating a Double Linked List Node. Inherits from the SLNode class. Fundamental for the Doubly Linked List data structure.

Module Contents#

class src.pydasa.structs.lists.ndlt.Node#

Bases: Generic[pydasa.structs.types.generics.T]

Node base class for creating Single Linked List Node or SLNode and Double Linked List Node or DLNode. Fundamental for the Linked List and Doubly Linked List data structures.

Parameters:

Generic (T) – Generic type for a Python data structure.

Returns:

A node object with the following attributes:
  • _data: The data stored in the node.

Return type:

Node

property data: pydasa.structs.types.generics.T#

data Property to read the data in the Node. Acts as a getter (get()) for the _data attribute.

Returns:

data stored in the Node.

Return type:

T

__str__()#

__str__() function to return a string representation of the Node. It also extendes for the SLNode and DLNode classes.

Returns:

string representation of the Node.

Return type:

str

__repr__()#

__repr__() function to return a string representation of the Node. It also extendes for the SLNode and DLNode classes.

Returns:

string representation of the Node.

Return type:

str

class src.pydasa.structs.lists.ndlt.SLNode#

Bases: Node[pydasa.structs.types.generics.T]

SLNode class for creating a Single Linked List Node. Inherits from the Node class. Fundamental for the Linked List data structure.

Parameters:
  • Node (dataclass) – Node base class for creating single and double linked nodes.

  • Generic (T) – Generic type for a Python data structure.

Returns:

A single linked node object with the following attributes:
  • _data: The data stored in the node.

  • _next: The next node of the same type.

Return type:

SLNode

property next: SLNode[T] | None#

next() Property to read the next node in the list. Acts as a getter (get()) for the _next attribute.

Returns:

reference to the next node of the list. If there is no next node, it returns None.

Return type:

Optional[“SLNode[T]”]

__str__()#

__str__() function to return a string representation of the SLNode. It also extends the Node class.

Returns:

string representation of the SLNode.

Return type:

str

__repr__()#

__repr__() function to return a string representation of the SLNode. It also extends the Node class.

Returns:

string representation of the SLNode.

Return type:

str

class src.pydasa.structs.lists.ndlt.DLNode#

Bases: SLNode[pydasa.structs.types.generics.T]

DLNode class for creating a Double Linked List Node. Inherits from the SLNode class. Fundamental for the Doubly Linked List data structure.

Parameters:
  • SLNode (dataclass) – SLNode class for creating a single linked list node.

  • Generic (T) – Generic type for a Python data structure.

Returns:

A double linked node object with the following attributes:
  • _data: The data stored in the node.

  • _next: The next node of the same type.

  • _prev: The previous node of the same type.

Return type:

DLNode

property prev: DLNode[T] | None#

prev() Property to read the previous node in the list. Acts as a getter (get()) for the _prev attribute.

Returns:

reference to the previous node of the list.

Return type:

node (Optional[“DLNode[T]”])

__str__()#

__str__() function to return a string representation of the DLNode. It also extends the Node class.

Returns:

string representation of the DLNode.

Return type:

str

__repr__()#

__repr__() function to return a string representation of the DLNode. It also extends the Node class.

Returns:

string representation of the DLNode.

Return type:

str