Try to do it first
This looks like a school assignment to me. If others give you the(ir) answer, you won't learn anything from it. So you really should (at least) try to solve it first.
Ask for help for existing code
Don't worry, we're here to help!
Post your solution and we can point out mistakes and help you make it better.
Clean the requirements
For starter, the instruction is not clear.
Why? Well, how do you merge the two arrays? What are the actual requirements?
Given array a (a1, a2, ..., an) and b (b1, b2, ..., bm) and start index in array a: k, where b will start to be inserted; what is the merge logic?
- It could be that the whole b is put into that k location within a: a1, a2, ..., ak, b1, b2, ..., bm, ak+1, ak+2, ..., an.
- Or starting from index k, you put elements of a and b alternating into the result array: a1, a2, ..., ak, b1, ak+1, b2, ak+2, b3, ..., an-1, bn-k, an, bn-k+1, bn-k+2, ..., bm.
- Or starting from index k, you merge into the result by taking the smallest of the next elements from a or b. So for instance for a = [1, 3, 7, 9] and b = [2, 4, 5, 6, 8] and k = 2 you would have the following result: a1, a2, b1, b2, b3, b4, a3, b5, a4, which is 1, 3, 2, 4, 5, 6, 7, 8, 9.
And one could come up with many more logics for merge. I think clearing up the requirements is the first step.
When you know what is exactly needed, try to write the code. If you need help, please, share what you have done so far (including what exactly the requirements are) and we'll be more than happy to help.
Good luck!