You are on page 1of 11

HASH FUNCTIONS

Data: 257
h(n) = n mod 11
h(257) = 257 mod 11

0
1 2 3 4 5 6 7 8 9 10

132 102 15 5 257 558 32

h(257) = 4

h(420) = 2

h(54) = 10
The floor of x, denoted ⌊ x ⌋, is the greatest integer less than or equal to x.
The ceiling of x, denoted ⌈ x ⌉, is the least integer greater than or equal to x.

The floor of x “rounds x down” while the ceiling of x “rounds x up.”

-3 -2 -1 0 1 2 3

⌊ 8.3⌋ = 8, ⌈ 9.1 ⌉ = 10, ⌊ -8.7 ⌋ = -9,

⌈ -11.3 ⌉ = -11, ⌈ 6 ⌉ = 6, ⌈ -8 ⌉ = -8
P (3.7) = 29 + 23 ⌈ 3.7 - 1 ⌉
= 29 + 23 ⌈ 2.7⌉
= 29 + 23 ⋅ 3 = 98

P (2) = 29 + 23 ⌈ 2 - 1 ⌉
= 29 + 23 ⌈ 1 ⌉
=29 + 23 ⋅ 1 = 52
INJECTIVE, SURJECTIVE AND
BIJECTION/BIJECTIVE

(FROM EXAMPLE 2.7.13 TO 2.7.20)


Injective, Surjective and Bijective/Bijection

A General Function points from each member of "A" to a member of "B".


It never has one "A" pointing to more than one "B", so one-to-many is not OK in a function
But more than one "A" can point to the same "B" (many-to-one is OK)

Injective means we won't have two or more "A"s pointing to the same "B".
So many-to-one is NOT OK (which is OK for a general function).
As it is also a function one-to-many is not OK
But we can have a "B" without a matching "A"
Injective is also called "One-to-One“

f = {(1, b), (3, a), (2, c)} from X = {1, 2, 3} to Y = {a, b, c, d}


Surjective means that every "B" has at least one matching "A" (maybe more than one).
There won't be a "B" left out.

Bijective means both Injective and Surjective together.


Think of it as a "perfect pairing" between the sets: every one has a partner and no one is left out.
So there is a perfect "one-to-one correspondence" between the members of the sets

{Bijective functions have an inverse!


If every "A" goes to a unique "B", and every "B" has a matching "A" then we can go back and forwards
without being led astray.}
COMPOSITION
Composition = is applying one function to the results of another:
the result of g( ) is sent through f( )
written as (f º g)(x) which means f(g(x))

Ex: f(x) = 2x+3 and g(x) = x2

x2 to 2x2 +3 (f º g)(x) = 2x2+3


Ps: be careful of the position of ‘g’ and ‘f’ as it will be different answer
(g º f)(x) which means g(f(x))
= (g º f)(x) = (2x+3)2

Not to be confused the circle with the dot as the dot is multiply
Binary operation
An operation that needs two inputs. A simple example is the addition operation "+":
In 2 + 3 = 5 the operation is "+", which takes two values (2 and 3) and gives the result 5

The two inputs are called "operands".

Also, a binary operation should take and return things of the same type! In other words, the operands and the result
must belong to the same Set.

A function from X × X into X is called a binary operator on X .


Let X = {1, 2, 3, . . . . .}
If we define f (x, y) = x + y
then f is a binary operator on X .

Let X = {a, b, c}.


If we define f (s, t) = st
Where s and t are strings over X and st is the concatenation of s and t, then f is a binary operator on X*,
Unary operation.
An operation that has only one input.
Example: the square root function.

√(16) = 4 has just one input "16" to produce an output of 4

A function from X into X is called a unary operator on X.

There are many more: factorial, sine, cosine, etc. are all unary operations.

Let U be a universal set. If we define


f (X) = x̄ , X ⊆ U,
Then f is is a unary operator on P (U)

You might also like