Question: Describe an algorithm that determines whether a function from a finite set to another finite set is one-to-one
Code/Algorithm:
Procedure one-to-one([A=(a1,a2,a3, …], [B= b1, b2, b3 …] : integers)
for i = 1 to m
k = 0 (counter variable)
for j = 1 to n
if Aj = Bi then k = k+1
if k ==! (doesn’t equal) 1 then return false
if k = 1 then return true