data_structures.linked_list.print_reverse ========================================= .. py:module:: data_structures.linked_list.print_reverse Attributes ---------- .. autoapisummary:: data_structures.linked_list.print_reverse.linked_list Classes ------- .. autoapisummary:: data_structures.linked_list.print_reverse.LinkedList data_structures.linked_list.print_reverse.Node Functions --------- .. autoapisummary:: data_structures.linked_list.print_reverse.in_reverse data_structures.linked_list.print_reverse.make_linked_list Module Contents --------------- .. py:class:: LinkedList A class to represent a Linked List. Use a tail pointer to speed up the append() operation. .. py:method:: __iter__() -> collections.abc.Iterator[int] Iterate the LinkedList yielding each Node's data. >>> linked_list = LinkedList() >>> items = (1, 2, 3, 4, 5) >>> linked_list.extend(items) >>> tuple(linked_list) == items True .. py:method:: __repr__() -> str Returns a string representation of the LinkedList. >>> linked_list = LinkedList() >>> str(linked_list) '' >>> linked_list.append(1) >>> str(linked_list) '1' >>> linked_list.extend([2, 3, 4, 5]) >>> str(linked_list) '1 -> 2 -> 3 -> 4 -> 5' .. py:method:: append(data: int) -> None Appends a new node with the given data to the end of the LinkedList. >>> linked_list = LinkedList() >>> str(linked_list) '' >>> linked_list.append(1) >>> str(linked_list) '1' >>> linked_list.append(2) >>> str(linked_list) '1 -> 2' .. py:method:: extend(items: collections.abc.Iterable[int]) -> None Appends each item to the end of the LinkedList. >>> linked_list = LinkedList() >>> linked_list.extend([]) >>> str(linked_list) '' >>> linked_list.extend([1, 2]) >>> str(linked_list) '1 -> 2' >>> linked_list.extend([3,4]) >>> str(linked_list) '1 -> 2 -> 3 -> 4' .. py:attribute:: head :type: Node | None :value: None .. py:attribute:: tail :type: Node | None :value: None .. py:class:: Node .. py:attribute:: data :type: int .. py:attribute:: next_node :type: Node | None :value: None .. py:function:: in_reverse(linked_list: LinkedList) -> str Prints the elements of the given Linked List in reverse order >>> in_reverse(LinkedList()) '' >>> in_reverse(make_linked_list([69, 88, 73])) '73 <- 88 <- 69' .. py:function:: make_linked_list(elements_list: collections.abc.Iterable[int]) -> LinkedList Creates a Linked List from the elements of the given sequence (list/tuple) and returns the head of the Linked List. >>> make_linked_list([]) Traceback (most recent call last): ... Exception: The Elements List is empty >>> make_linked_list([7]) 7 >>> make_linked_list(['abc']) abc >>> make_linked_list([7, 25]) 7 -> 25 .. py:data:: linked_list