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

What is the difference between CriteriaQuery and CreateQuery in Hibernate???? Thanks in advance!!!!!!

1 Answers   Accenture,


I want sample papers for NIC Examination. Plz send them to my mail Id das.neelam@gmail.com . Plz send it today, tomorrow i've the exam.

0 Answers  


how many logical drive we can form to physical device in our computer?

1 Answers   nvidia,


3.Give the formula for determine the range of the data type?

1 Answers  


5. Which of the following can you do with DB2 Express- C? Query databases with SQL Query databases with XML using XQuery and XPath Use SQL in Xquery and Xquery in SQL All of the above

0 Answers  


what is difference between input parameter and output parameter.

0 Answers   NIIT,


I am looking for selenium RC online Training in chennai. can any one tell me the best institute

0 Answers  


Given an array of size n+1 which contains all the numbers from 1 to n.Find the number which is repeated in O(n) time.How do you proceed with the same with floating numbers from 0 to 1 instead of 1 to n?

0 Answers   Amazon,


how many languages .net is supporting now?

4 Answers  


hoe to data grid use in sql server 2000?

0 Answers   HCL,


How many ways we can fill a dataset in .Net

1 Answers   iGate,


give idea for creating screen in abap

0 Answers  


Categories