Computer Science I / Functions
Practice question · Select all that apply

Each option lists a set of ordered pairs from {1, 2, 3} to {a, b}. Select every one that is a function on the whole of {1, 2, 3}.

Hints
  1. A function must assign to EACH element of the domain EXACTLY ONE output, so check both halves of that requirement.
  2. One option gives an input two outputs, and one option leaves an input with none.
Show the answer
  • A. {(1,b), (2,b), (3,b)}
  • D. {(1,a), (2,a), (3,b)}
  • E. {(1,a), (2,b), (3,a)}
Why

Options 1, 3 and 5 assign exactly one output to each of 1, 2 and 3. Option 2 gives 1 two outputs, so it is a relation but not a function; option 3 leaves 3 unassigned, so it is not defined on the whole domain. Several inputs sharing one output is perfectly allowed, that only costs injectivity, not functionhood.

Read the lesson: Functions →

Practise Functions

The app has 4 more questions on this lesson, and keeps your place in the course. Computer Science I is free to start.

More questions on Functions