Write a program using mergesort technique.
Answer / Saurabh Agarwal
Here's an implementation of Merge Sort in Python:n```pythonndef merge_sort(arr):n if len(arr) <= 1:n return arrn mid = len(arr) // 2n left = merge_sort(arr[:mid])n right = merge_sort(arr[mid:])n return merge(left, right)ndef merge(left, right):n result = []n i, j = 0, 0n while i < len(left) and j < len(right):n if left[i] <= right[j]:n result.append(left[i])n i += 1n else:n result.append(right[j])n j += 1n result += left[i:]n result += right[j:]n return result
| Is This Answer Correct ? | 0 Yes | 0 No |
What is the Difference between sax and dom parser?
List some applications of tree-data structure?
Which is the fastest sorting?
What is ascii sort order?
What is data structure explain in detail?
What is hashing in cyber security?
What are the advantages of bubble sort?
Can you distinguish between ArrayList and Array?
How will you free the memory that is allocated at run time?
What is meant by strongly connected in a graph?
How many parts are there in a declaration statement using data structures?
What is the difference between hashset and hashmap?