25. Suppose we wish to merge two lists. Each list is already sorted and we want the merged list to also be sorted. Pleas
Posted: Sat May 14, 2022 4:43 pm
25. Suppose we wish to merge two lists. Each list is already sorted and we want the merged list to also be sorted. Please implement the solution using recursion (ie, calling yourself to process the rest of the list). You can assume that the parameters passed are actual lists (.e., not just an atom) and does not contain sub-lists (ie, it is a flat list). You are prohibited from merging the lists first then sorting the merged list. Some examples: > (my-merge '(4 5 6) '(1 2 3)) (1 2 3 4 5 6) > (my-merge *(1 3 5) (2 4 6)) (1 2 3 4 5 6) > (my-merge '(1 2) (1 2 3 4 5)) *(1 1 2 2 3 4 5) ?- my_merge([4, 5, 6), (1, 2, 3), Result). Result = (1, 2, 3, 4, 5, 6]. ?- my_merge([1, 3, 5), (2, 4, 6), Result). Result = [1, 2, 3, 4, 5, 6). ?- my_merge([1, 2], [1, 2, 3, 4, 5). Result). Result [1, 1, 2, 2, 3, 4, 5). Write a Rocket forebin (my-merge lit) let 2) thot murns a list as shown above Write your solutions on the next page. 8