Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please Write a Python Code for the following question 3. (6 points) Write a function called merge-sort that takes a list and return a sorted
Please Write a Python Code for the following question
3. (6 points) Write a function called merge-sort that takes a list and return a sorted copy. The following pseudo-code describes the merge sort algorithm. It uses recurisve calls, where a function is called inside its definition. Merge Sort (1) (a) if the length of the list / is 1 return the list (b) if the length of the list l is more than 1 split it into two halfs i. Sort the first half using merge sort (recursive call) ii. Sort the second half using merge sort (recursive call) iii. Combine both halfs using the merge function from question (2) above iv. return the resulting list Test your function with the following line of code. print (merge_sort([2, 3, 3, -1, 22, 19, 100, 4, 5, 12])) You should get the following output [-1, 2, 3, 3, 4, 5, 12, 19, 22, 100] Process finished with exit code 0Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started