+ 1
What is simple n short program of union of two array in c
5 Respuestas
+ 4
This is the basic algorithm:
Given sorted arrays of known length, result array could be allocated as the sum of the lengths. Declare three indexes all zero (one for each array.) While there are elements to put into the output, process them.
If a and b both still have elements to process, compare them. If equal, move one to c and increment both indexes of a & b. If a's less, move it and increment it's index. Otherwise, move b's and increment it's index.
Otherwise, one of the arrays is done so copy the rest of the other.
Create a C source and link it here, if you need more help. I'll comment step by step updates to you to complete the working code.
+ 3
I'm not exactly sure what you are trying to ask. Can you give a sample input and output?
+ 2
How do original arrays get created? Hard coded or input? Do you know enough C to code it, if you were told how?
+ 1
if a[1,2,3] and b[3,4,5] then output should be c[1,2,3,4,5]
0
sir,here I just take a simple pre define array... once I get the logic I will try to take the input from user