Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

Discrete Mathematics for Computer Science (MAT2DMX)

Assignment 1 – Sets, relations, functions, number systems, and combinatorics


Question 1

(a) B = {5, 10, 15}

(b) A ∩ B = {5, 10}; A ∪ B = {5, 6, 9, 10, 11, 12, 15}

(c) P(B) = {∅, {5}, {10}, {15}, {5, 10}, {5, 15}, {10, 15}, {5, 10, 15}}

(d) The cardinality of A × B is 18.

Question 2

(a) X = {(Banana, Fruit), (Potato, Vegetable), (Banana, Vegetable), (Pumpkin, Fruit)}

For each ordered pair in X, the first element is from set A and the second element is from set
B. Therefore, X is a relation from A to B.

(b) Y = {(Banana, Fruit), (Potato, Vegetable), (Potato, Meat)}

For the first two ordered pairs in Y, the first element is from set A and the second element is
from set B. However, in the third ordered pair (Potato, Meat), the second element "Meat" is
not from set B. Therefore, Y is not a relation from A to B.

Question 3

(i) f(x) + g(x) To find the sum of the two functions, we simply add their corresponding terms.
3 2
f ( x)=−x +2 x −1
3
g( x )=−x +3 x+2
Now, let's add the functions:
3 2 3
f ( x)+ g( x )=(−x + 2 x −1)+(−x +3 x+ 2)
Combine like terms:
3 3 2
f ( x)+ g( x )=−x −x +2 x +3 x−1+2
Simplify:
3 2
f ( x)+ g( x )=−2 x + 2 x +3 x+1
So, the simplified sum of the functions is:
3 2
f (x)+ g(x )=−2 x + 2 x +3 x+1
(ii) f(x) × g(x) To find the product of the two functions, we multiply each term in f(x) by each term in
g(x).
3 2
f (x)=−x +2 x −1
3
g(x )=−x +3 x+2
Now, let's multiply the functions:
3 2 3
f (x)× g( x )=(−x + 2 x −1)(−x + 3 x +2)
Use the distributive property to multiply each term in f(x) by each term in g(x):
3 3 3 3 2 3 2 2 3
f (x)× g( x )=(−x )(−x )+(−x )(3 x )+(−x )(2)+(2 x )(−x )+(2 x )(3 x)+(2 x )(2)+(−1)(−x )+(−1)(3 x )+(−1
)

Simplify each term:


6 4 3 5 3 2 3
f (x)× g( x )=x −3 x +2 x −2 x + 6 x −4 x + x −3 x+ 2
Combine like terms:
6 5 4 3 2
f (x)× g( x )=x −2 x −3 x +9 x −4 x −3 x+2
So, the simplified product of the functions is:
6 5 4 3 2
f (x)× g( x )=x −2 x −3 x +9 x −4 x −3 x+2

Question 4

(a) Simplify the expression x^(−2𝑦/3) × (𝑥^(2𝑦/3))^2. Explain what rules you use in each step.

Step 1: Apply the power rule (a^(m))^n = a^(mn) to the second term.

(−2 y /3 ) (2 y /3) 2 (−2 y /3 ) (4 y /3)


x ×(x ) =x ×x

Step 2: Apply the product rule a^m * a^n = a^(m+n) to combine the terms.

(−2 y /3 ) (4 y /3) ((−2 y /3)+(4 y/ 3))


x ×x =x

Step 3: Add the exponents.

((−2 y/ 3)+(4 y /3)) (2 y /3)


x =x
Question 5

(a) 100112 in decimal is calculated as:

4 3 2 1 0
1 ×10 + 0 ×10 +0 ×10 +1 ×10 +1 ×10 =10000+0+ 0+ 10+1=10011

(b) 6𝐹𝐶16 in decimal is calculated as:


2 1 0
6 ×16 + 15× 16 +12× 16 =6 ×256+15 ×16 +12× 1=1536+240 +12=1788

(c) Dividing 286 by 2, we get:


286 ÷ 2 = 143 with a remainder of 0

Next, divide 143 by 2: 143 ÷ 2 = 71 with a remainder of 1

Continuing to divide by 2:
71 ÷ 2 = 35 with a remainder of 1
35 ÷ 2 = 17 with a remainder of 1
17 ÷ 2 = 8 with a remainder of 1
8 ÷ 2 = 4 with a remainder of 0
4 ÷ 2 = 2 with a remainder of 0
2 ÷ 2 = 1 with a remainder of 0

1 ÷ 2 = 0 with a remainder of 1 Reading the remainders from the bottom to the top, we get the
binary representation: 286 in binary is 100011110.

Therefore, 286 in binary is 100011110.

(d) Dividing 1231 by 8, we get:


1231 ÷ 8 = 153 with a remainder of 7

Next, divide 153 by 8:


153 ÷ 8 = 19 with a remainder of 1

Continuing to divide by 8:
19 ÷ 8 = 2 with a remainder of 3
2 ÷ 8 = 0 with a remainder of 2

Reading the remainders from the bottom to the top, we get the octal representation: 1231 in
octal is 2317.
Therefore, 1231 in octal is 2317.

Question 6

(a)

Summand 1 1 0 1 1 0 1
Summand 2 1 1 0 1 1
Carrying 1 1 1 1 0 0
Result 1 1 0 0 0 1 3

Conclusion: 1011012 + 110112 = 1100013 in base 2.

(b)

Summand 1 7 3 5 8
Summand 2 2 1 6 8
Carrying 1 0 2 1
Result 1 0 2 2 1 4

Conclusion: 7358 + 2168 = 102214 in base 8.

(c)

Summand 1 C F 8 1 6
Summand 2 3 A 9 1 6
Carrying 1 0 E 8 1
Result 1 0 2 9 A C

Conclusion: CF816 + 3A916 = 1029AC16 in base 16.

Question 7

(a) (i) To find the total number of different barcodes, we need to consider the number of
possibilities for each character in the barcode.

There are 26 capital letters in the alphabet and 10 digits (0-9).

For the first 3 characters, which are capital letters, there are 26 choices for each character. So,
there are 26 * 26 * 26 possibilities for the first 3 characters.
For the next 4 characters, which are digits, there are 10 choices for each character. So, there
are 10 * 10 * 10 * 10 possibilities for the next 4 characters.

To find the total number of different barcodes, we multiply the possibilities for each character
together:

Total barcodes = 26 * 26 * 26 * 10 * 10 * 10 * 10 = 175,760,000

(ii) If letters can be repeated, but digits cannot be repeated, the calculation changes.

For the first letter, there are still 26 choices. However, for the second and third letters, since
repetition is allowed, there are also 26 choices each.

For the first digit, there are 10 choices. However, for the second, third, and fourth digits, since
repetition is not allowed, the choices reduce by 1 each time. So there are 9 choices for the
second digit, 8 choices for the third digit, and 7 choices for the fourth digit.

To calculate the total number of different barcodes, we multiply the number of choices for
each position: 26 * 26 * 26 * 10 * 9 * 8 * 7 = 786,240.

Therefore, the company can generate 786,240 different barcodes using this format.

(b) In the new barcode format, each barcode contains either 3 or 4 capital letters followed by either
4 or 5 digits.

For the case of 3 letters and 4 digits, we can use the same calculation as in part (a)(i). Therefore,
the number of different barcodes for this case is 17,576,000.

For the case of 4 letters and 5 digits, the calculations are as follows:

For the first letter, there are 26 choices. For the second, third, and fourth letters, since repetition
is allowed, there are 26 choices each.

For the first digit, there are 10 choices. However, for the second, third, fourth, and fifth digits,
since repetition is not allowed, the choices reduce by 1 each time. So there are 9 choices for the
second digit, 8 choices for the third digit, 7 choices for the fourth digit, and 6 choices for the fifth
digit.

To calculate the total number of different barcodes, we add the number of different barcodes for
each case: 17,576,000 + (26 * 26 * 26 * 10 * 9 * 8 * 7 * 6) = 18,028,080.

Therefore, the company can generate a total of 18,028,080 different barcodes using this new
format.
Question 8

(a)

Step 1: Count the total number of students who know java or python individually. We are given that
14 students know java and 16 students know python. So, there are 14 + 16 = 30 students who know
java or python.

Step 2: Count the total number of students who know at least one language (Java or Python). We
are given that there are 20 students who know at least one language.

Step 3: Subtract the total number of students who know at least one language from the total
number of students who know Java or Python. Using the Inclusive-Exclusive Principle, we can write
this as: Total students who know Java or Python - Total students who know at least one language =
Students who know both Java and Python.

So, 30 - 20 = 10 students who know both Java and Python.

Step 4: Final answer. Therefore, there are 10 students in this class who know both Java and Python.

(b)

Step 1: Count the total number of students who can speak French or Japanese individually. We are
given that 10 students can speak Japanese and 9 students can speak French.

Step 2: Count the total number of students who can speak at least one language (French or
Japanese). We are given that there are 5 students who can speak both French and Japanese.

Step 3: Add the total number of students who can speak French or Japanese and subtract the
number of students who can speak at least one language. Using the Inclusive-Exclusive Principle, we
can write this as: Total students who can speak French or Japanese - Total students who can speak at
least one language = Students who cannot speak French or Japanese.

So, (10 + 9) - 5 = 14 students who cannot speak French or Japanese.

Step 4: Final answer. Therefore, there are 14 students in this class who cannot speak French or
Japanese.

Question 9

(a) To find the number of different strings of 6 characters that can be made from 8 characters (A, B,
C, D, E, F, G, H) without repetition, we can use the concept of permutations.
In this case, we have 8 options for the first character, 7 options for the second character (as one
character has been used), 6 options for the third character, and so on.

The number of different strings can be calculated as the product of these options:
8 ×7 × 6 ×5 × 4 ×3=20,160

(b) To find the number of different choices of 3 subjects that a student can make from 8 available
subjects, we can again use the concept of permutations.

In this case, we need to choose 3 subjects out of 8 without repetition. The order of the chosen
subjects matters since they start and end at the same time.

The number of different choices can be calculated as the number of permutations of 8 subjects
taken 3 at a time:

8 P 3=8 ! ÷ ( 8−3 ) !=8! ÷ 5 !=( 8 ×7 × 6 ) ÷ ( 3 ×2 ×1 )=56

Question 10

(a) To find the number of arrangements where the IT consultant visits exactly 3 clients between
bank clients A and B (with A visited before B), we can consider the arrangement as a sequence of
clients.

The sequence can be represented as follows:

A___B

Where the blanks represent the positions for the other clients. We need to fill these positions
with the remaining 5 clients.

The number of ways to arrange the remaining 5 clients in the blanks is given by the permutations
of 5 clients taken 5 at a time:

5P5 = 5! = 5 * 4 * 3 * 2 * 1 = 120

Therefore, there are 120 different arrangements where the IT consultant visits exactly 3 clients
between bank clients A and B, with A visited before B.

(b) To find the number of arrangements where the IT consultant visits at least 3 clients between
bank clients A and B (including A before B and B before A), we can consider two cases:

Case 1: A visited before B


In this case, we have already considered the arrangements where exactly 3 clients are visited
between A and B. The remaining clients can be arranged in any order, so the number of
arrangements is given by the permutations of 5 clients taken 5 at a time:
5P5 = 5! = 5 * 4 * 3 * 2 * 1 = 120

Case 2: B visited before A

In this case, we can treat B as the first client visited and A as the last client visited. The
remaining 5 clients can be arranged in any order in between. So, the number of arrangements is
again given by the permutations of 5 clients taken 5 at a time:

5P5 = 5! = 5 * 4 * 3 * 2 * 1 = 120

To get the total number of arrangements, we sum the arrangements from both cases:

Total arrangements = 120 + 120 = 240 Therefore, there are 240

different arrangements where the IT consultant visits at least 3 clients between bank clients A
and B, including both A before B and B before A.

You might also like