Page 379 - CA_Blue( J )_Class10
P. 379
15.5.5 Merging
Merging of array means concatenating of two arrays. The two different arrays of different size are merged to the third
array.
Let us take an example,
index 0 1 2
ar1 10 20 30
index 0 1 2 3
ar2 40 50 60 70
There are two arrays: ar1 of size 3 and ar2 of size 4. These two arrays will be merged to the third array ar3.
index 0 1 2 3 4 5 6
ar3
Step 1:
index 0 1 2
ar1 10 20 30
index 0 1 2 3 4 5 6
ar3
All the elements of the array ar1 will be copied to the array ar3 keeping the index same.
Step 2:
index 0 1 2 3
ar2 40 50 60 70
index 0 1 2 3 4 5 6
ar3 10 20 30
All the elements of the array ar2 will be copied to the array ar3 starting from the next empty index position.
Step 3:
index 0 1 2 3 4 5 6
ar3 10 20 30 40 50 60 70
The third array ar3 will have all the elements of ar1 and ar2.
15.6 SORTING AND SEARCHING
Sorting Searching
Arranging the array elements in ascending or Finding an element in the array.
descending order.
Two types of sorting are Bubble sort and Selection Two types of searching are Linear search and Binary
sort. search.
377
Arrays 377

