MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / Intersection

Function Intersection

Arrays/16_Set_Operation.c:48–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46 return arr3;
47}
48struct Array* Intersection(struct Array *arr1,struct Array
49*arr2)
50{
51 int i,j,k;
52 i=j=k=0;
53
54 struct Array *arr3=(struct Array *)malloc(sizeof(struct
55Array));
56
57 while(i<arr1->length && j<arr2->length)
58 {
59 if(arr1->A[i]<arr2->A[j])
60 i++;
61 else if(arr2->A[j]<arr1->A[i])
62 j++;
63 else if(arr1->A[i]==arr2->A[j])
64 {
65 arr3->A[k++]=arr1->A[i++];
66 j++;
67 }
68 }
69
70 arr3->length=k;
71 arr3->size=10;
72
73 return arr3;
74}
75struct Array* Difference(struct Array *arr1,struct Array
76*arr2)
77{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected