In: Computer Science
You must write each of the following scheme functions. You must use only basic scheme functions do not use third-party libraries to support any of your work. Do not use any function with side effects.
Write a function (merge-sorter L1) that takes list-of-integers L1 and returns all elements of L1 in sorted order. You must use a merge-sort technique that, in the recursive case, a) splits L1 into two approximately-equal-length lists, b) sorts those lists, and then c) merges the lists to obtain the result. See the following examples for clarificaton.
(merge-sorter '(3 1 5 4 2) ---> (1 2 3 4 5) (merge-sorter '()) ---> () (merge-sorter '(1)) ---> (1)
PYTHON PROGRAMMING FOR MERGE SORT:-
OUTPUT:-
1.
Enter the no of element in the array: 5
Enter the element of this array:
3
1
5
4
2
Given input array is:
[3, 1, 5, 4, 2]
Sorted array is:
[1, 2, 3, 4, 5]
2.
Enter the no of element in the array: 0
Enter the element of this array:
Given input array is:
[]
Sorted array is:
[]
3.
Enter the no of element in the array: 1
Enter the element of this array:
1
Given input array is:
[1]
Sorted array is:
[1]
4.
Enter the no of element in the array: 6
Enter the element of this array:
13
11
14
5
7
6
Given input array is:
[13, 11, 14, 5, 7, 6]
Sorted array is:
[5, 6, 7, 11, 13, 14]