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

Method Diff

Arrays/18_Menu_Based_problem.cpp:307–333  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

305 return arr3;
306}
307Array* Array::Diff(Array arr2)
308{
309 int i,j,k;
310 i=j=k=0;
311
312 Array *arr3=new Array(length+arr2.length);
313
314 while(i<length && j<arr2.length)
315 {
316 if(A[i]<arr2.A[j])
317 arr3->A[k++]=A[i++];
318 else if(arr2.A[j]<A[i])
319 j++;
320 else
321 {
322 i++;
323 j++;
324 }
325 }
326 for(;i<length;i++)
327 arr3->A[k++]=A[i];
328
329
330 arr3->length=k;
331
332 return arr3;
333}
334int main()
335{
336 Array *arr1;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected