In a modified merge sort, the input array is splitted at a position on...
The time complexity is given by: T(N) = T(N/3) + T(2N/3) + N Solving the above recurrence relation gives, T(N) = N(logN base 3/2)
View all questions of this test
In a modified merge sort, the input array is splitted at a position on...
Explanation:
Merge sort is a divide and conquer algorithm that recursively divides the input array into two halves, sorts them independently, and then merges the sorted halves to obtain a sorted array. The time complexity of merge sort is usually expressed as O(NlogN), where N is the length of the input array.
In this modified version of merge sort, the input array is split at a position one-third of the length(N) of the array. Let's analyze the time complexity of this modified merge sort.
Splitting the Array:
When the array is split at one-third of its length, the size of each subarray is approximately N/3. This splitting process continues recursively until the subarrays have a size of 1.
Sorting the Subarrays:
Since each subarray has a size of N/3, the time complexity to sort each subarray is O((N/3)log(N/3)). This is because we are sorting a subarray of size N/3 using the modified merge sort algorithm.
Merging the Sorted Subarrays:
The merging process in merge sort takes linear time. In this case, the merging step takes O(N) time because we are merging two subarrays of size N/3 each.
Total Time Complexity:
To calculate the total time complexity of this modified merge sort, we need to consider the time complexity of splitting, sorting, and merging.
The splitting process occurs recursively, dividing the array into two halves at each level. Since the array is split at one-third of its length, the number of levels in the recursion tree is logN base 3. Therefore, the time complexity of splitting is O(N(logN base 3)).
The sorting process occurs at each level of the recursion tree and has a time complexity of O((N/3)log(N/3)).
The merging process occurs at each level as well and takes O(N) time.
Since the splitting, sorting, and merging occur independently, we can sum up their time complexities to obtain the total time complexity.
Total Time Complexity = O(N(logN base 3)) + O((N/3)log(N/3)) + O(N)
Simplifying the expression, we get:
Total Time Complexity = O(N(logN base 3))
Therefore, the tightest upper bound on the time complexity of this modified merge sort is N(logN base 3), which is option 'A'.
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).