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

Function Difference

Arrays/16_Set_Operation.c:75–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73 return arr3;
74}
75struct Array* Difference(struct Array *arr1,struct Array
76*arr2)
77{
78 int i,j,k;
79 i=j=k=0;
80
81 struct Array *arr3=(struct Array *)malloc(sizeof(struct
82Array));
83
84 while(i<arr1->length && j<arr2->length)
85 {
86 if(arr1->A[i]<arr2->A[j])
87 arr3->A[k++]=arr1->A[i++];
88 else if(arr2->A[j]<arr1->A[i])
89 j++;
90 else
91 {
92 i++;
93 j++;
94 }
95 }
96 for(;i<arr1->length;i++)
97 arr3->A[k++]=arr1->A[i];
98
99
100 arr3->length=k;
101 arr3->size=10;
102
103 return arr3;
104}
105int main()
106{
107 struct Array arr1={{2,9,21,28,35},10,5};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected