Method for splitting linked list with only recursion
<p>I'm having trouble programming a recursive method that will split linked list into sub linked list. I don't want to use any arrays or any types of loops as well. </p>

<p>For example I have a linked like this: [2]->[52]->[23]->[45]->[98]->[10]</p>

<p>I want: [2]->[52]->[23] and [45]->[98]->[10]</p>

<p>Then: [2]->[52] and [23] and  [45]->[98] and [10] and so on.</p>

<p>The code I am using for my linked list is following:</p>

<pre><code>public static class ListNode{
    int value;
    ListNode next;
    public ListNode(int value){
        this.value = value;
        this.next = null;
    }
}

public ListNode(int value, ListNode next){
    this.value = value;
    this.next = next;
}

public static int listLength(ListNode node){
    if (node == null)
        return 0;
    return 1 + listLength(node.next);
}
</code></pre>

<p>I tried doing this but it doesn't seem to work, count is a global I have declared in my class.</p>

<pre><code>public static ListNode divide(listNode head){
    listNode left = head;
    listNode right = left;

    if(head == null || head.next == null){
        return null;
    }
    if (count &lt;= listLength(head)/2){
        divide(left.next);
    }
    if (count &gt; listLength(head)/2 &amp;&amp; count &lt;= listLength(head)){
        divide(right.next);
    }
    return head;
}
</code></pre>