data_structures.linked_list.merge_two_lists =========================================== .. py:module:: data_structures.linked_list.merge_two_lists .. autoapi-nested-parse:: Algorithm that merges two sorted linked lists into one sorted linked list. Attributes ---------- .. autoapisummary:: data_structures.linked_list.merge_two_lists.SSL data_structures.linked_list.merge_two_lists.test_data_even data_structures.linked_list.merge_two_lists.test_data_odd Classes ------- .. autoapisummary:: data_structures.linked_list.merge_two_lists.Node data_structures.linked_list.merge_two_lists.SortedLinkedList Functions --------- .. autoapisummary:: data_structures.linked_list.merge_two_lists.merge_lists Module Contents --------------- .. py:class:: Node .. py:attribute:: data :type: int .. py:attribute:: next_node :type: Node | None .. py:class:: SortedLinkedList(ints: collections.abc.Iterable[int]) .. py:method:: __iter__() -> collections.abc.Iterator[int] >>> tuple(SortedLinkedList(test_data_odd)) == tuple(sorted(test_data_odd)) True >>> tuple(SortedLinkedList(test_data_even)) == tuple(sorted(test_data_even)) True .. py:method:: __len__() -> int >>> for i in range(3): ... len(SortedLinkedList(range(i))) == i True True True >>> len(SortedLinkedList(test_data_odd)) 8 .. py:method:: __str__() -> str >>> str(SortedLinkedList([])) '' >>> str(SortedLinkedList(test_data_odd)) '-11 -> -1 -> 0 -> 1 -> 3 -> 5 -> 7 -> 9' >>> str(SortedLinkedList(test_data_even)) '-2 -> 0 -> 2 -> 3 -> 4 -> 6 -> 8 -> 10' .. py:attribute:: head :type: Node | None :value: None .. py:function:: merge_lists(sll_one: SortedLinkedList, sll_two: SortedLinkedList) -> SortedLinkedList >>> SSL = SortedLinkedList >>> merged = merge_lists(SSL(test_data_odd), SSL(test_data_even)) >>> len(merged) 16 >>> str(merged) '-11 -> -2 -> -1 -> 0 -> 0 -> 1 -> 2 -> 3 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 -> 9 -> 10' >>> list(merged) == list(sorted(test_data_odd + test_data_even)) True .. py:data:: SSL .. py:data:: test_data_even .. py:data:: test_data_odd