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

Respected Sir/Mem Plz send me all 5 years solved question papers of sbi clerk on my Gmail id and that is chandelmishel@gmail.com

2345


A, B, C made trips to PIZZA centre B made 2.4 times more trips then ! , C made 6 more then A Total Min trips are

1180


Two cars are 15 kms apart. One is turning at a speed of 50kmph and the other at 40kmph . How much time will it take for the two cars to meet?

1374


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

1150


A&B fill 3 litres and 5 litres of oil in the car. C pays Rs. 8/- to A7B. How much will A get?

1366


What kind of questions comes in Analytical/Aptitude test in Wipro Bpo?

7484


The perimeter of a rhombus is 52 units. One of its diagonal is 24 units.What is its second diagonals length?

1499


If DBMDVUUB = CALCUTTA Then BOMBAY = ?

2129


A man shows his friend a woman sitting in a park and says that she the daughter of my grandmother's only son. What is the relation between the two

1361


The average salary of Ram, Shyam and Sundar is 95 Rs. per week. If Ram earns Rs.115 and Shyam earns Rs.65.What is the salary of Sundar.

1135


There are two trees in a lawn. One grows at a rate 3/5 of the other in 4 years. If the total growth of trees is 8 ft. What is the height of the smaller tree after 2 years

1293


There are 5 red shoes, 4 green shoes. If one draw randomly a shoe what is the probability of getting red shoe

1285


7) Jane works at a fashion design company, and is having problems getting dressed for work. She refuses to wear any color combination that does not go well together as many of her clients may look down upon this. She has two pairs of skirts, brown and blue; three blouses, white, sky blue, and gray; four pairs of stockings, red, black, brown, and blue; and two pairs of shoes, black and brown. The blue skirt cannot be worn with red or brown stockings. Gray does not go well with brown. Black does not go well with brown. If Jane wears black shoes she will not wear: a) red stockings. b) a blue skirt. c) a white blouse. d) blue stockings. e) a sky blue blouse. 8) Jane works at a fashion design company, and is having problems getting dressed for work. She refuses to wear any color combination that does not go well together as many of her clients may look down upon this. She has two pairs of skirts, brown and blue; three blouses, white, sky blue, and gray; four pairs of stockings, red, black, brown, and blue; and two pairs of shoes, black and brown. The blue skirt cannot be worn with red or brown stockings. Gray does not go well with brown. Black does not go well with brown. If Jane is color blind and is unable to determine what outfits went well together, how many possible clothing combinations could she have? a) 24 b) 32 c) 36 d) 44 e) 48 9) Jane works at a fashion design company, and is having problems getting dressed for work. She refuses to wear any color combination that does not go well together as many of her clients may look down upon this. She has two pairs of skirts, brown and blue; three blouses, white, sky blue, and gray; four pairs of stockings, red, black, brown, and blue; and two pairs of shoes, black and brown. The blue skirt cannot be worn with red or brown stockings. Gray does not go well with brown. Black does not go well with brown. If Jane wears a brown skirt and a white blouse, she could: a) not wear blue stockings. b) not wear brown shoes. c) not wear black shoes. d) wear blue stockings. e) wear red stockings. 10) Jane works at a fashion design company, and is having problems getting dressed for work. She refuses to wear any color combination that does not go well together as many of her clients may look down upon this. She has two pairs of skirts, brown and blue; three blouses, white, sky blue, and gray; four pairs of stockings, red, black, brown, and blue; and two pairs of shoes, black and brown. The blue skirt cannot be worn with red or brown stockings. Gray does not go well with brown. Black does not go well with brown. Jane buys a gray scarf. If she wears the new scarf, then she could: a) not wear blue stockings. b) not wear brown stockings. c) not wear black shoes. d) wear a white blouse. e) wear black stockings. 11) Jane works at a fashion design company, and is having problems getting dressed for work. She refuses to wear any color combination that does not go well together as many of her clients may look down upon this. She has two pairs of skirts, brown and blue; three blouses, white, sky blue, and gray; four pairs of stockings, red, black, brown, and blue; and two pairs of shoes, black and brown. The blue skirt cannot be worn with red or brown stockings. Gray does not go well with brown. Black does not go well with brown. Jane will never wear: a) blue and red together. b) white and red together. c) gray and blue together. d) white and black together. e) white and red together. 12) Two men, Barry and David, and two women Ann and Cathy are doctors. One is a surgeon, one a dentist, one an optometrist, and one is a general practitioner. They are seated around a square table, with one person on each side. 1) Barry is across from the dentist. 2) David is not across from the surgeon. 3) The optometrist is on Ann's immediate left. 4) Cathy is the general practitioner. 5) The surgeon and general practitioner are married to each other. 6) The general practitioner is not on Cathy's immediate left. 7) The general practitioner is across from the optometrist. Which of the following must be true? a) Barry is the dentist. b) The surgeon and general practitioner are women. c) The dentist is across from the surgeon. d) David is the surgeon. e) Cathy is across from Ann. 13) Two men, Barry and David, and two women Ann and Cathy are doctors. One is a surgeon, one a dentist, one an optometrist, and one is a general practitioner. They are seated around a square table, with one person on each side. 1) Barry is across from the dentist. 2) David is not across from the surgeon. 3) The optometrist is on Ann's immediate left. 4) Cathy is the general practitioner. 5) The surgeon and general practitioner are married to each other. 6) The general practitioner is not on Cathy's immediate left. 7) The general practitioner is across from the optometrist. If both women leave the table, the a) optometrist and dentist remain. b) surgeon and optometrist remain. c) surgeon and general practitioner remain. d) general practitioner and dentist remain. e) general practitioner and optometrist remain.

2616


Numbers of animals is 11 more than the number of birds. If the number of birds were the number of animals and number of animals were the number of birds( ie., interchanging number s of animals and birds.), the total number of legs get reduced by one fifth(1/5). How many no. of birds and animals were there?

1792


sam and mala have a conversation. sam says i am vertainly not over 40. mala says i am 38 and you are atleast 5 years older than me. Now sam says you are atleast 39. all the sattements by the two are false. How hold are they realy.

1497