Insert a Node at the Tail of a Linked List

  • + 1 comment

    I think you can trim one line out of your non-recursive solution:

    def Insert(head, data):
        if head == None:
            return Node(data, None)
        curr_node = head
        while curr_node.next != None:
            curr_node = curr_node.next
        curr_node.next = Node(data, None)
        return head