CS 201 Lecture 8 - Functions
CS 201 Lecture 8 - Functions
Kholoud Nairoukh
Department of Computer Science
German-Jordanian University
Lecture 8
• A function can be naturally generalized to the
concept of assigning elements of any set to
elements of any set. (Also known as a map.)
f A B
• •
f • •
a• • • y
b •
•
•
•
A x
B Bipartite Graph Plot
Like Venn diagrams
Dr. Kholoud Nairoukh
• If it is written that f:A→B, and f(a)=b
(where aA & bB), then we say:
– A is the domain of f. We also say
– B is the codomain of f. the signature
of f is A→B.
– b is the image of a under f.
– a is a pre-image of b under f.
• In general, b may have more than 1 pre-
image.
– The range RB of f is R={b | a f(a)=b }.
• Example: x3
– Converse is not necessarily true. Example: 1/x