You are viewing a single comment's thread. Return to all comments →
Can anybody help me with this. Node Insert(Node head,int data) { if(head==null){ Node head1=new Node(); head=head1; head.data=data; return head; } else{ Node node=new Node(); Node temp=head; while(temp!=null){ temp=temp.next; } temp=node; temp.next=null; temp.data=data; 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 →
Can anybody help me with this. Node Insert(Node head,int data) { if(head==null){ Node head1=new Node(); head=head1; head.data=data; return head; } else{ Node node=new Node(); Node temp=head; while(temp!=null){ temp=temp.next; } temp=node; temp.next=null; temp.data=data; return head; } }