data_structures.linked_list.has_loop

Attributes

root_node

Exceptions

ContainsLoopError

Common base class for all non-exit exceptions.

Classes

Node

Module Contents

exception data_structures.linked_list.has_loop.ContainsLoopError

Bases: Exception

Common base class for all non-exit exceptions.

class data_structures.linked_list.has_loop.Node(data: Any)
__iter__()
data: Any
property has_loop: bool

A loop is when the exact same Node appears more than once in a linked list. >>> root_node = Node(1) >>> root_node.next_node = Node(2) >>> root_node.next_node.next_node = Node(3) >>> root_node.next_node.next_node.next_node = Node(4) >>> root_node.has_loop False >>> root_node.next_node.next_node.next_node = root_node.next_node >>> root_node.has_loop True

next_node: Node | None = None
data_structures.linked_list.has_loop.root_node