Computer Science and Discrete Mathematics
Computer Science and Discrete Mathematics
Discrete Mathematics
Computer representation
of relations and digraphs
WE KNOW THIS ALREADY
Data can be stored in a list
known as an array. The
locations of an array are
consecutively numbered in a
computer memory.
Example:
Array by the name of A with 5 data items:
Index
Location
A [1] D1 Data 1
A [2] D2
Data 2
A [3] D3 Data 3
A [4] D4
Data 4
A [5] Data 5
D5
D1 3 [2]
D2 5 [3]
D5 0 [4]
D3 1
[5]
The pointer tells us what location to go to next. Start at
D1 location at A [2]. P[2] points to location [3]. D2 is in
location A [3].
Location P[3] points to location A[5]. D3 is in location A [5].
Location P[5] points to location A[1]. D4 is in location A [1].
Location P[1] points to location A[4]. D5 is in location A [4].
When you get to A[4], P[4] contents is 0 which means you
are done.
2 2 1 8
7 5
1 4 3 3
5
10 6
9 6 4
R = {(1,2),(1,6),(1,3),(2,1),(2,3),(3,5),(3,4),(3,6),(5,4),(6,
1)}
An array called VERT for Vertex contains a pointer for
every vertex in the digraph. The digraph has 6
vertices, so the VERT array will have 6 locations.
edge (1,6)
(1,3)
(1,2)
0 done with edges leaving vertex 1
Next look at vertex position [2]
edge (2,1)
(2,3)
0 done with edges leaving vertex 2
Next look at vertex position [3]
edge (3,4)
(3,5)
(3,6)
0 done with edges leaving vertex 3
Next, look at vertex position [4]
It is 0 so done with edges leaving vertex 4.
Next look at vertex position [5]
edge (5,4)
0 done with edges leaving vertex 5
Last look at vertex 6
edge (6,1)
0 done with edges leaving vertex 6
FUNCTIONS FOR COMPUTER
SCIENCE
1. Characteristic Function
2. Factorial Function
3. Factorial Function
4. Floor and Ceiling Function
5. Polynomial Function
6. Base 2 Exponential Function
7. Logarithmic Function
8. Boolean Function
9. Hashing Function
Which memory locations are assigned by the hashing
function h(k) = k mod 101 to the records of insurance
company customers with these Social Security
numbers?
a) 104578690
b) 432222187
c) 372201919
d) 501338753