Discrete Mathematics for Computer Science

(Romina) #1
Basic Definitions 235

The function exp : R -R IR defined as exp(x) = ex and shown in Figure 4.18 is 1-1
but not onto.

y

70-
60"
50
40"
30-
20-
10

-4 -2 2 4

Figure 4.18 exp(x).

The functions defined here have been constructed to show that the two properties 1-1
and onto are independent of each other. Two properties of a mathematical object are inde-
pendent if objects exist that can have exactly one of the properties, both of the properties,
or neither of the properties. For 1-1 and onto functions, the four functions shown in Figures
4.15 through 4.18 demonstrate that the properties 1-1 and onto are independent.
Commonly used synonyms exist for the properties of functions defined in Definitions
6, 7, and 8. A 1-1 function is also called an injective function, or an injection. An onto
function is called a surjective function, or a surjection. A 1-1 correspondence is called a
bijective function, or a bijection. Also, a 1-1 correspondence is often referred to simply
as a 1-1 and onto function.

Application: Hashing Functions
When you put a bank card into an ATM and enter your pin number, your bank account
records must be found so that your transaction can be authorized. This is an example of in-
formation in symbolic or numeric form (the information on the magnetic stripe on the ATM
card) being used to determine a location on some storage device (the physical location of
your records). A function that can take information as input and find a storage address as
an output is called a hashing function. For simplicity, at this point we will assume that a
hashing function is 1-1.

Example 17. Define a hashing function that uses 63 storage locations as a four-stage
process with surnames as input. The first step is to replace the letters of the surname with
integers according to the following rule: A -- 1, B -+ 2, C -+ 3 ... , Y -> 25, Z --> 26.
The second step is to multiply the letter value by 2i where i is the letter's position in the
word, with the leftmost character being in position 1. The third step is to add the values
that represent the letters of the surname. The final step is to divide this sum by 63. The
hashing value is the remainder of this division. For example, Robb has a value of 144
and a hashing value of 18. You should imagine that the information needed for Robb is in

Free download pdf