Vinay C Lab
Vinay C Lab
3
When pivot element= 7
4
When pivot element= 8
Partitioned Partitioned
Step array=[1,5,7,9,8,10] Step array=[1,5,7,8,9,10]
Merge sort
• Merge sort is another divide-and-
conquer algorithm that divides the
array into smaller segments.
Space Complexity:
Auxiliary Space: O(n)
Temporary arrays are used for merging
subarrays.
Recursive Stack Space: O(logn)
Due to recursive function call
Example
For the array[12,11,13,5,6,7]