How do I write an algorithm that tests if a relation on a matrix is a function

Hello all!

I have a problem that I don't know where to start with. I have to write an algorithm that finds out if a relation is a function. Okay, the question goes like this:

*Write an algorithm that receives as input the matrix A of relation R on set X and tests whether R is a function. The matrix A will be n x n , where n = |X|. Find the best-case and worst-case number of comparisons used by your algorithm in terms of n.*

Does anyone know how to write this algorithm? I hope so because I'm stuck.

Cheers,

Henrik