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

8.In DSP,Define Signal and System?and various type of signals.

0 Answers  


I am taking the bmc control m/enterprise manager 7.0 scheduling test and just wanted to see what kind of questions they would ask or if anyone has taken the test and how long it is for how many questions?

0 Answers  


HOW TO BREAK THE FIREWALL?

0 Answers   ME,


what is programmable BIST in today ic design

0 Answers   IIT,


what is the last ant version you worked?how to get it

0 Answers  






what is runtime exception and compiletime exception ?

1 Answers   Accenture,


Is class is a abstract datatype in java?

0 Answers  


what is dynamic polymorphism?

2 Answers   Satyam,


what is the abap/4

1 Answers  


Piggy backing is a technique for a) Flow control b) sequence c) Acknowledgement d) retransmition

17 Answers   Fast Booking, HCL, Lucent, NIC,


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

0 Answers   Patni,


how much fee for deccan soft institute .how to block seat for sandeep sir class reply soonnnn 

0 Answers  


Categories