Created
May 2, 2020 13:15
-
-
Save Mahdhir/5499e3093e9d2998663e308c1d631be6 to your computer and use it in GitHub Desktop.
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
public void insertAtEnd(int new_data) { | |
Node new_node = new Node(new_data); | |
if (head == null) { | |
head = new Node(new_data); | |
return; | |
} | |
new_node.next = null; | |
Node last = head; | |
while (last.next != null) | |
last = last.next; | |
last.next = new_node; | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment