Given an array A storing m integer values and an array B sto
Given an array A storing m integer values and an array B storing n integer values, write in pseudocode an algorithm subarray(A, B, m, n) that returns the value true if A is a sub-array of B and it returns false otherwise. A is a sub-array of B if there is a value 0 lessthanorequalto j lessthanorequalto n - m such that A[0] = B[j], A[1] = B[j + 1], middot middot middot, A[m] = B[j + m - 1], i.e., if the values of A appear in consecutive positions of B. For example, for the arrays A and B shown below the algorithm must return the value true, but for the arrays A\' and B, the algorithm must return the value false.
Solution
bool subarray(a[], b[], m, n)
{
i = 0;
quickSort(a, 0, m-1);
for (i=0; i<n; i++)
{
if (binarySearch(a, 0, m-1, b[i]) == -1)
return false;
}
return true;
}
