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

If VXUPLVH is written as SURMISE, what is SHDVD?

2262


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 ?

1544


A shopkeeper bought a watch for Rs.400 and sold it for Rs.500.What is his profit percentage?

1564


epaulet : shoulder : : ring :?

1829


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.

1121


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?

1358


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.

2633


f(f(x))=81 THEN VALUE OF X=

1278


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

2675


‘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. ?

1376


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 __.

1453


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

1182


All people use a bus paid equalty. 40 seats in the bus.Bus charge is Rs. 70.37. How many seats we left unfilled?

1285


If wind flows 160 miles in 330 min, for 80 miles how much time required.

1278


3 angles or 3 sides r given. Which will form a triangle?

1277