You are viewing a single comment's thread. Return to all comments →
static SinglyLinkedListNode insertNodeAtTail(SinglyLinkedListNode head, int data) {
SinglyLinkedListNode temp = head; SinglyLinkedListNode a = new SinglyLinkedListNode(data); if(temp == null){ temp = a; return temp; } while(temp.next !=null){ temp=temp.next; } temp.next = a; temp = a; return head;
}
Seems like cookies are disabled on this browser, please enable them to open this website
Insert a Node at the Tail of a Linked List
You are viewing a single comment's thread. Return to all comments →
SinglyLinkedListNode temp = head; SinglyLinkedListNode a = new SinglyLinkedListNode(data); if(temp == null){ temp = a; return temp; } while(temp.next !=null){ temp=temp.next; } temp.next = a; temp = a; return head;