How to merge two different arrays which are already sorted to build a sorted array | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to merge two different arrays which are already sorted to build a sorted array

16th Dec 2016, 1:17 PM
Avnish Chauhan
Avnish Chauhan - avatar
2 Answers
+ 2
1. make new array with correct size. 2. make 2 int variables. index1 and index2. 3. compare values of array1 at index1 and array2 at index2. 4. copy the lower value into the new array. 5. increment the index of the array from which you copied. done
16th Dec 2016, 1:36 PM
Peter
- 1
use mergesort algorithm
16th Dec 2016, 5:11 PM
Vijeth Belle
Vijeth Belle - avatar