def initialize(): head = Node(-1) linked = LinkedList(head) # Create continuous node to head for i in range(0, 5): linked.add_end(i) # Printing out the result print("Print Linked List Iterate Result") # expected to show) -1, 0, 1, 2, 3, 4 linked.to_string() return head, linked
def test_merge(): print("Merging, expect to see 2, 3, 5, 10, 15, 20") # initialize the given first list first_head = Node(5) first_list = LinkedList(first_head) first_list.add_end(10) first_list.add_end(15) # initialize the given second list second_head = Node(2) second_list = LinkedList(second_head) second_list.add_end(3) second_list.add_end(20) new_list = first_list.sorted_merge(second_list) new_list.to_string()