1. You are given a partially written LinkedList class. 2. You are required to complete the body of mergeSort function. The function is static and is passed the head and tail of an unsorted list. The function is expected to return a new sorted list. The original list must not change. 3. Input and Output is managed for you. Note - Watch the question video for theory of merge sort.
Input Format
Input is managed for you
Output Format
Output is managed for you
Constraints
1. O(nlogn) time complexity required.
Notice
Try First, Check Solution later
1. You should first read the question and watch the question video.2. Think of a solution approach, then try and submit the question on editor tab.3. We strongly advise you to watch the solution video for prescribed approach.Example
Input
6 10 2 19 22 3 7
Output
2 3 7 10 19 22 10 2 19 22 3 7