In a modified merge sort, the input array is splitted at a position on...
If we use recursion tree first we have n elements then two subparts n/3 and 2n/3
Assume a tree here
n divided in to n/3 and 2n/3
n/3 divided in to n/9 and 2n/9 ( this tree goes on left side and vanishes to 1 element)
2n/3 divided in to 2n/9 and 4n/9 ( here 4n/9 part grows even left side is vanished)
so we will have time complexity based on deepest height
and the elements in that is n -->n/(3/2) ----> n/(3/2)^2 ---> n/(3/2)^3---> .. 1
Solving the above equation we get n * logn/log(3/2) = n logn/log(3/2).
To learn more about Sorting algorithms:
View all questions of this test
In a modified merge sort, the input array is splitted at a position on...
Explanation:
In the modified merge sort, the input array is split at a position one-third of the length(N) of the array. This means that the array is divided into two parts, one part being two-thirds of the array and the other part being one-third of the array.
Time Complexity of Merge Sort:
- In the regular merge sort algorithm, the time complexity is given by T(N) = 2T(N/2) + O(N), where T(N) represents the time complexity of sorting an array of size N.
- This is because the array is recursively divided into two halves, and then the two halves are merged.
- The time complexity of merging two sorted arrays of size N/2 is O(N). Therefore, the overall time complexity is O(N logN).
Modified Merge Sort:
- In the modified merge sort, the array is split at a position one-third of the length(N) of the array.
- This means that one part of the array is of size 2N/3 and the other part is of size N/3.
- The larger part of the array is recursively sorted using the modified merge sort algorithm.
- The smaller part of the array is sorted using a different algorithm or a simpler version of merge sort.
- Finally, the two sorted parts are merged.
- The time complexity of sorting the larger part of the array remains the same as the regular merge sort, i.e., O((2N/3) log(2N/3)).
- The time complexity of sorting the smaller part of the array is not specified, but let's assume it to be O((N/3) log(N/3)).
- The time complexity of merging the two sorted parts is O(N).
- Therefore, the overall time complexity of the modified merge sort can be approximated as O((2N/3) log(2N/3) + (N/3) log(N/3) + N).
Worst Case Time Complexity:
- In the worst case, the time complexity is determined by the larger part of the array, which is O((2N/3) log(2N/3)).
- As N approaches infinity, the base of the logarithm becomes insignificant, and we can simplify the time complexity to O(N logN).
- Therefore, the worst case time complexity of the modified merge sort is O(N logN).
Answer:
The correct answer is option 'D', N(logN base 3/2).
To make sure you are not studying endlessly, EduRev has designed Computer Science Engineering (CSE) study material, with Structured Courses, Videos, & Test Series. Plus get personalized analysis, doubt solving and improvement plans to achieve a great score in Computer Science Engineering (CSE).