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

Delta 5 weight scale not connect with oracle application what i can do?

0 Answers  


what are methods we have in connection pooling

1 Answers   Wipro,


what is the maximam caption size of lebel

1 Answers  


along with oracle which language will be beneficial to have knowledge with,java,.net,since i m doing oracle have appeared for 8th sem BEIT,plz suggest

0 Answers  


Artficial language is provided which of the language?

3 Answers   Geometric Software,






What is the maximum amount of memory any single process on Windows can address? Is this different than the maximum virtual memory for the system? How would this affect a system design?

2 Answers  


which property is used to display the advertisements with adrotator control

0 Answers   Sonata,


what are other resources are needed for this mantis?

0 Answers  


how MATLSB software suitable for electrical branch? which tools are useful??

1 Answers  


i am getting the error while compiling my cics program with including db2 dclgen member it is showing that ur dclgen member not including and all the host variables are undeclared

0 Answers   TCS,


There are 2 tables: EMP : EmpId, Ename, Sal, DeptId DEPT : DeptId, Dname Write a query to find out emp names and their department names. if any emp has null in Deptid the it shows ?No Department?. Write a query to find out those department names which has no employee. Write a query to find out those employees whose salary is greater than their department?s average salary.

1 Answers   Oracle,


what are the top level class of interface in java?

2 Answers   Satyam,


Categories