Created
March 21, 2014 06:03
-
-
Save gurdasnijor/9680450 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function MergeLists(list1, list2) { | |
if (!list1) return list2; | |
if (!list2) return list1; | |
if (list1.data < list2.data) { | |
list1.next = MergeLists(list1.next, list2); | |
return list1; | |
} else { | |
list2.next = MergeLists(list2.next, list1); | |
return list2; | |
} | |
} | |
list1 = new LLNode(0,new LLNode(1, new LLNode(3,null))) | |
list2 = new LLNode(2,new LLNode(7, new LLNode(9,null))) | |
MergeLists(list1,list2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment