Using the Merge Sort technique is an effective method because both arrays are already sorted. By using this method, we can apply a similar method to merge sort.
Algorithm1. Create an auxiliary array of size N + M. 2. Initialize two pointers i & j to 0.3. Pointer i points to 1st array, whereas pointer j points to 2nd array.