def insert_at_end(head, data): | |
new_node = Node(data) | |
current = head | |
while current.next: # traversing till the last node | |
current = current.next | |
# change the next of last node | |
current.next = new_node | |
return head |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment