Quote:

Given two arrays, find the number of elements of the first one that are also members of the second array. The elements in both arrays are sorted.

int commonElementsIteratively( int a[], int n, int b[], int m)

int commonElementsRecursively( int a[], int n, int b[], int m)

n is the number of elements in a and m contains the number of elements in b. Each function, independently, computes the number of elements of a that are members of b. The first function uses loops to do its work while the second one uses recursion for this purpose. Since the elements are sorted, both solutions should run in linear time with respect to the sum of n and m. It is okay for you to change the signature of the recursive function if you find it useful to do so.

int sumIteratively( int a[], int n)