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

Method Inter

Arrays/18_Menu_Based_problem.cpp:283–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

281 return arr3;
282}
283Array* Array::Inter(Array arr2)
284{
285 int i,j,k;
286 i=j=k=0;
287
288 Array *arr3=new Array(length+arr2.length);
289
290 while(i<length && j<arr2.length)
291 {
292 if(A[i]<arr2.A[j])
293 i++;
294 else if(arr2.A[j]<A[i])
295 j++;
296 else if(A[i]==arr2.A[j])
297 {
298 arr3->A[k++]=A[i++];
299 j++;
300 }
301 }
302
303 arr3->length=k;
304
305 return arr3;
306}
307Array* Array::Diff(Array arr2)
308{
309 int i,j,k;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected