Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

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

2728


"what category of job are you looking for and why"asked from an mep engineer.

2221


1/3 of girls and 1/2 of boys is goto canteen. What factor & total no. of class mates goto canteen.

1364


15 lit of water containing 20 % of alcohol ,then added 5 lit of water .What is the % of alcohol?

1242


720 buses operate from a depot, but 168 are being repaired. What percentage of the total that are in service?

1858


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.

1176


i want rrb tc exam previous pepers

2517


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?

1390


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.

1362


analogy: cell: tissue::atom:?

1364


In a arithmetic reason 10,9,60,90,70 and 66.. .whats the next number with conclusion

2115


+ means * and * means / and / means % what is the value of these question 2+3*5/7 it was two question of these type.

1198


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

2402


How many 3 digits with 3 Distinct digits are there from 100-1000.

1139


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?

1226