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

Answers were Sorted based on User's Feedback



There are two sorted arrays a1 and a2 of size n1 and size n2 respectively. array a1 is full array..

Answer / 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

There are two sorted arrays a1 and a2 of size n1 and size n2 respectively. array a1 is full array..

Answer / surjeet gangwar

import java.util.*;
class arrtest
{
int[][] a=new int[3][3];
int[][] b={{1,1,1},{1,1,1},{1,1,1}};

public arrtest()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the matrix:\n");
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
a[i][j]=sc.nextInt();
}

void oper()
{
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
if(a[i][j]==0)
for(int k=0;k<3;k++)
{
b[i][k]=0;
b[k][j]=0;
}
}

void print()
{
System.out.println(" the matrix:\n");
for(int i=0;i<3;i++)
{ for(int j=0;j<3;j++)
System.out.print("\t"+b[i][j]);

System.out.println("\n");
}
}
}
class arrdemo
{
public static void main(String a[])
{
arrtest at=new arrtest();
at.oper();
at.print();
}
}

Is This Answer Correct ?    0 Yes 3 No

Post New Answer

More General Aptitude Interview Questions

which country is following one party system

0 Answers   SSC,


REPUBLICAN = 108 so DEMOCRATE = ?

3 Answers   Citicorp, COSL, PAF, Wipro,


Give me some Aptitude test questions and answers asked in I.T field interviews?

1 Answers   Randstad, SanDisk, TCS,


guttural : throat :: gastric :

0 Answers   IBM,


If "basis points" are defined so that 1 percent is equal to 100 basis points, then 75.5 percent is how many basis points greater than 65.5 percent?

5 Answers   Wipro,


FULL FORM OF R.O.S.H.A.N

0 Answers  


A sheet of paper has statements numbered from 1 to 40. For each value of n from 1 to 40, statement n says "At least n of the statements on this sheet are true." Which statements are true and which are false? The first 13 statements are true and the rest are false. The first 26 statements are false and the rest are true. The odd numbered statements are true and the even numbered are false. The even numbered statements are true and the odd numbered are false

1 Answers   TCS,


The ratio for Boys to Girls is 6:4. 60% of the boys and 40% of girls take lunch in the canteen. What % of class takes lunch in canteen.

0 Answers   Infosys,


a file s transferred from one location to another in buckets . the size of bucket s 10 kilobytes. the buckets get filled at rate of 0.0001kb per ms. transmission time from sender to receiver s 10ms per bucket. after receipt of bucket, receiver sends an acknowledgement tat reches sender in 100 ms. assuming no error during transmission write a formula to calculate time taken in seconds to successfully complete transfer of file of size N kb.

5 Answers   TCS, Tech Mahindra,


xy-x+2y = 6 equation is shifted to form equation xy=c what is c?

5 Answers   Geometric Software,


In the 4 digits 1,2,3,4 how many 4 digited numbers are possible which are divisable by 4? Repetetions are allowed

0 Answers   Infosys,


Integral ET(epsiolan transpose)*sigma*dV P=strain displacement vector Q=stress-strain deformation Find [K]

0 Answers  


Categories