Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Pinterest
Share On Reddit
Share On Stumbleupon
Contact us
Hide Buttons

Alternate Splitting of a given Linked List

Objec­tive: Given a singly linked list, split it into two linked lists. These linked lists will con­tain the alter­nate nodes from the given linked list.





  • Make two point­ers(headA and headB) and set it to head and next just to fix the head­ers for the new linked list.
  • Make Node cur­rN­ode = head and Node t =
  • Do the tra­ver­sal of the linked list.
  • Make next = and = (Split­ting step).
  • Keep check­ing whether next!=null &&!=null.

Com­plete Code:



You may also like...