-
-
Save alexnikol/1c644c3b8ec1a67dea2d331406e1570c to your computer and use it in GitHub Desktop.
Insert a Node at the Tail of a Linked List. Realization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from linked_list import SinglyLinkedListNode | |
def insertNodeAtTail(head, data): | |
if head is None: | |
return SinglyLinkedListNode(data) | |
else: | |
current_node = head | |
while current_node.next is not None: | |
current_node = current_node.next | |
current_node.next = SinglyLinkedListNode(data) | |
return head |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment