There are two sorted arrays
a1 and a2 of size n1 and size n2 respectively.
array a1 is full
array a2 has exactly n1(size of array a1) empty space.
example
a1[]=1234
a2[]=56789_ _ _ _
Write a function to merge these two arrays to form a sorted
array without any extra memory use.
i want a solution in c/c++ language
Answer Posted / ajay
class A
{
public static void main(String args[])
{
int[] a1={1,2,3,4};
int[] a2=new int[9];
a2[0]=5; a2[1]=6; a2[2]=7; a2[3]=8; a2[4]=9;
for(int i=8;i>=4;i--)
a2[i]=a2[i-4];
for(int i=0;i<=3;i++)
a2[i]=a1[i];
for(int i=0;i<=8;i++)
System.out.println(a2[i]);
}
}
| Is This Answer Correct ? | 2 Yes | 1 No |
Post New Answer View All Answers
If VXUPLVH is written as SURMISE, what is SHDVD?
In a digital circuit which was to implement (A B) + (A)XOR(B), the designer implements (A B) (A)XOR(B) What is the probability of error in it ?
A shopkeeper bought a watch for Rs.400 and sold it for Rs.500.What is his profit percentage?
epaulet : shoulder : : ring :?
Two trains move in the same direction at 50 kmph and 32 kmph respectively. A man in the slower train observes the 15 seconds elapse before the faster train completely passes by him.
an orange galss has orange juice. and white glass has apple juice. Bothe equal volume 50ml of the orange juice is taken and poured into the apple juice. 50ml from the white glass is poured into the orange glass. Of the two quantities, the amount of apple juice in the orange glass and the amount of orange juice in the white glass, which one is greater and by how much?
5) Write a program that takes a 3 digit number n and finds out whether the number 2^n + 1 is prime, or if it is not prime find out its factors.
f(f(x))=81 THEN VALUE OF X=
I am writing the APSRTC OUT post.so i dont know the managerial aptitude.If any one know about this or refer any book, please give the information to my Mail id is narayanansg@gmail.com
‘a‘ number of persons work daily ‘b’ hours to produce ‘c’ items. If ‘d’ persons walks away from the group what will be the number of hours to produce ‘c’ items. ?
A positive integer which when added to 1000 gives a sum which is greater than 10.06 when it is multiplied by 100 this positive integer is __.
in a mixture, R is 2 parts, S is 1 part. in order to make S to 25% of the mixture, howmuch R is to be added
All people use a bus paid equalty. 40 seats in the bus.Bus charge is Rs. 70.37. How many seats we left unfilled?
If wind flows 160 miles in 330 min, for 80 miles how much time required.
3 angles or 3 sides r given. Which will form a triangle?