Hey rtrumpow.

You could initialize a 1-D array that is the size of the set B and iterate through all elements in A and increment array[f(x)] by 1 where x is an element of A.

In other words

array = new int[SizeOfSetB];

InitializeArrayToAllZeros(array);

for (x = 1 to SizeOfSetA)

{

elementOfA = SetA[x];

array[function(elementOfA)]++;

}

onto = true;

for (i = 1 to SizeOfSetB)

{

if (array[i] == 0)

{

onto = false;

break;

}

}

// onto contains status of onto.