You are viewing a single comment's thread. Return to all comments →
Below approach is with recursion
Node Insert(Node head,int data) { return insertDS(head, data, head); } Node insertDS(Node head, int data, Node parent){ if(head == null){ head = new Node(); head.data = data; if(parent != null) parent.next = head; }else insertDS(head.next, data, head); 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 →
Below approach is with recursion