• + 0 comments

    why not change the recursive part to this (java code):

    if(headA.data<headB.data){
        headA.next = MergeLists(headA.next,headB);
        return headA;
    }
    else{
        headB.next = MergeLists(headA,headB.next);
        return headB;
    }