write a program for finding the union of two integer array
in java?

Answers were Sorted based on User's Feedback



write a program for finding the union of two integer array in java?..

Answer / satish kumar

void union(int x[],int y[])
{


int n=x.length + y.length ;
int z[]=new int[n];
int p=x.length;
for(int i=0;i<x.length;i++)
{
z[i]=x[i];
}
int j=0;
for(int i=0;i<y.length;i++)
{
for(j=0;j<x.length;j++)
{
if(y[i]!=z[j])
{
continue;
}
else
{
if(y[i]==z[j])

break;
}
}
if(j==x.length)
z[p++]=y[i];
}

Is This Answer Correct ?    32 Yes 24 No

write a program for finding the union of two integer array in java?..

Answer / nadeem khokhar

the above mentioned code is also good one. but i m giving you an algorithm you can say, so you can get the concept and convert it into any language
int a[3]=1,2,3;
int b[3]=2,3,4;

for(int i=0; i <=2; i++)
{

for(int j=0; j<=2; j++)
{

if(a[i] == b[j])
cout<<a[i]; is a union of a and b
}
}

Is This Answer Correct ?    14 Yes 26 No

Post New Answer

More Programming Languages AllOther Interview Questions

Tell me the jobs for the MCA Fresher in delhi, Noida..

0 Answers  


is possible to delete specific data in a row by using of sql query?

0 Answers   HCL,


what is polymorphism in java.

3 Answers   Atos Origin,


3 members in a pf.how we read 3 members without using ovrdbf.using rg pgms....

0 Answers   CTS,


When we delete logfiles such as screenshots how does it affect the ldf file? Ive seen huge change while adding screenshots in the ldf file but a very minor one deleting them.Please Explain

0 Answers  






Artficial language is provided which of the language?

3 Answers   Geometric Software,


Write a shell program to test whether a given year is leap year or not ?

0 Answers   Patni,


what do u mean by html

5 Answers   Infosys,


how sap is different from other software ?

0 Answers  


What are the other ways to create an object with out calling new keyword in java?

2 Answers   HCL,


what is the similarity between networking devices?

0 Answers   Cygnus, Infosys,


what is meant by trigger?

8 Answers   IBM,


Categories