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
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
"what category of job are you looking for and why"asked from an mep engineer.
1/3 of girls and 1/2 of boys is goto canteen. What factor & total no. of class mates goto canteen.
15 lit of water containing 20 % of alcohol ,then added 5 lit of water .What is the % of alcohol?
720 buses operate from a depot, but 168 are being repaired. What percentage of the total that are in service?
Two glasses were filled with 1/3 and 1/4 milk. they were filled with water &then mixed in tumbler. what is the percentage of milk in the resultant.
i want rrb tc exam previous pepers
An article sold at a profit of 20% if both the cost price and selling price would be Rs.20/- the profit would be 10% more. What is the cost price of that article?
A worker pay Rs20 a day ,he works 1,1/3,2/3,1/8,3/4 in a week.What is the total amount paid to the worker.
analogy: cell: tissue::atom:?
In a arithmetic reason 10,9,60,90,70 and 66.. .whats the next number with conclusion
+ means * and * means / and / means % what is the value of these question 2+3*5/7 it was two question of these type.
On BRIC So called New york has risen by on average sales plese chewk the incorrect sentence option 1. so called 2. Has risen 3. By on average
How many 3 digits with 3 Distinct digits are there from 100-1000.
A, B, C, D, E, F, G, H, I are all of squares which are combined in a square. Area of B is 81 cm2. Side of A is 1 cm. Then find area of I?