I came up with this code which takes two SORTED in ascending order lists and then merges those two lists into one single list, preserving the ascending order-sortedness. I was trying to analyze it and see what the time complexity of it is. My belief is that in the worst case, we will have to traverse through the whole lists and since there are 2 lists we're gonna have to have a nested recurence, which means O(n^2) time for the WORST case. However, since we're comparing the sizes of each of the two elements before we recurse, I am thinking that this is probably O(log n) time. Correct me if I'm wrong please. Thanks
Here's my recursion:
mergeLists::[Integer]->[Integer]->[Integer]
mergeLists [] [] =[]
mergeLists [] (y:ys) =(y:ys)
mergeLists (x:xs) [] =(x:xs)
mergeLists (x:xs) (y:ys)
|(x<y) =x:mergeLists xs (y:ys)
|otherwise =y:mergeLists (x:xs) ys