Sunteți pe pagina 1din 4

1. With S1 = {2, 3, 5, 7}, S2 = {2, 4, 5, 8, 9}, and U = {1: 10}, compute S¯1∪S2.

Answer:
Given: U = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, S1 = {2, 3, 5, 7} and S2 = {2, 4, 5, 8, 9}
S¯1 = U – S1 = {1, 4, 6, 8, 9, 10}

S¯1∪S2 = {1, 4, 6, 8, 9, 10} ∪ {2, 4, 5, 8, 9}


= {1, 2, 4, 5, 6, 8, 9, 10}

2. With S1 = {2, 3, 5, 7} and S2 = {2, 4, 5, 8, 9}, compute S1 × S2 and S2 × S1.


Answer:
S = S1 × S2 = {(x, y): x ∈ S1, y ∈ S2}.
S = S2 × S1 = {(x, y): x ∈ S2, y ∈ S1}.

Given: S1 = {2, 3, 5, 7}
S2 = {2, 4, 5, 8, 9}

For S = S1 x S2 = {(2, 2), (2, 4), (2, 5), (2, 8), (2, 9), (3, 2), (3, 4), (3, 5), (3, 8), (3, 9), (5, 2), (5, 4), (5, 5), (5, 8), (5,
9), (7, 2), (7, 4), (7, 5), (7, 8), (7, 9)}.

For S = S2 x S1 = {(2, 2), (2, 3), (2, 5), (2, 7), (4, 2), (4, 3), (4, 5), (4, 7), (5, 2), (5, 3), (5, 5), (5, 7), (8, 2), (8, 3), (8,
5), (8, 7), (9, 2), (9, 3), (9, 5), (9, 7)}.

3. For S = {2, 5, 6, 8} and T = {2, 4, 6, 8}, compute |S ∩ T| + |S ∪ T|.


Answer:
Given S = {2, 5, 6, 8}
T = {2, 4, 6, 8}

∪  OR
∩  AND
Number of elements in the set (S U T): set (S OR T)
|S ∪ T| = n (S U T) = n {2, 4, 5, 6, 8} = 5
Number of elements in the set (S ∩ T): set (S AND T)
|S ∩ T| = n (S ∩ T) = n {2, 6, 8} = 3

Therefore |S ∩ T| + |S ∪ T| = 3 + 5 = 8

4. What relation between two sets S and T must hold so that |S ∪T | = |S|+|T |?
Answer:
|S ∪ T| = |S| + |T| − |S ∩ T| -- (bars || indicating enclosed set cardinality)
If there is no overlap between the two sets which is S ∩ T = ∅ and in turn |∅| = 0.
Hence: |S ∪ T| = |S| + |T| − |S ∩ T|
= |S| + |T| − |∅|
= |S| + |T| − 0
= |S| + |T|
Therefore, two sets S and T to hold relation |S ∪T | = |S|+|T |
S ∩ T should be ∅

Note: This scenario occurs when there are disjoint sets, which mean no elements were in common in sets.

5. Show that for all sets S and T, S−T=S∩T¯.


Answer:
If U is the universal set, then n(A¯) = n(U)-n(A)
Assumptions: U = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, T = {2, 4} and S = {2, 4, 5, 8, 9}

Case Scenario 1:
T¯ = {1,3,5,6,7,8,9,10}
S∩T¯ = {2, 4, 5, 8, 9} ∩ {1,3,5,6,7,8,9,10} = {5,8,9}
S−T = {2, 4, 5, 8, 9} - {2, 4} = {5,8,9}

Case Scenario 2: Following general addition rule


n(S) – n(T) = n(S∩T¯)
= n(S)+n (T¯) − n(S∪T¯)
= n(S) + n(n(U)-n(T)) −n (S∪ (n(U)-n(T))
= 5 + 8 – 10
=3
Where n(S) – n(T) = 5 – 2 = 3

Based on both scenarios we can say that for all sets of S and T, S−T=S∩T¯.

6. Prove DeMorgan’s laws, Equations (1.2) and (1.3), by showing that if an element x is in the set on one side
of the equality, then it must also be in the set on the other side of the equality.
Answer:
DeMorgan’s laws were shown below:
S1∪S2¯¯¯¯ = S¯1∩S¯2 --------------- (1.2)
S1∩S2¯¯¯¯= S¯1∪S¯2 --------------- (1.3)
complementation is another basic operation used. Denoted by S¯ is the complement of a set S, consists of all
elements not in S.
If U is universal set specified, then S¯= {x:x∈U, x∉S}
Assumptions:
U = {a, b, c, d, x, y}, S1 = {a, b, y} and S2 = {c, d, y}
S¯1 = U – (S1) = {a, b, c, d, x, y} – {a, b, y} = {c, d, x}
S¯2 = U – (S2) = {a, b, c, d, x, y} – {c, d, y} = {a, b, x}
S1 U S2 = {a, b, y} U {c, d, y} = {a, b, c, d, y}
S1 ∩ S2 = {a, b, y} ∩ {c, d, y} = {y}
S1 ∪ S2¯¯¯¯ = U – (S1 U S2) = {a, b, c, d, x, y} – {a, b, c, d, y} = {x}  L.H.S of Equation
S¯1 ∩ S¯2 = {c, d, x} ∩ {a, b, x} = {x}  R.H.S of Equation
S1 ∪ S2¯¯¯¯ = S¯1 ∩ S¯2 = {x}  Equation 1.2 Proved

S1 ∩ S2¯¯¯¯ = U – (S1 ∩ S2) = {a, b, c, d, x, y} – {y} = {a, b, c, d, x}  L.H.S of Equation


S¯1 U S¯2 = {c, d, x} U {a, b, x} = {a, b, c, d, x}  R.H.S of Equation
S1 ∩ S2¯¯¯¯ = S¯1 U S¯2 = {a, b, c, d, x}  Equation 1.3 Proved

7. Show that if S1 ⊆ S2, then S¯2⊆S¯1.


Answer:
Assumptions: U = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, S1 = {2, 3, 5, 7} and S2 = {2, 3, 4, 5, 7, 8, 9}
S¯1 = U – S1 = {1, 4, 6, 8, 9, 10}
S¯2 = U – S2 = {1, 6, 10}
Based on above:

S1 ⊆ S2 = {2, 3, 5, 7} ⊆ {2, 3, 4, 5, 7, 8, 9}  Condition Satisfied

Then verifying S¯2⊆S¯1:

S¯2⊆S¯1 = {1, 6, 10} ⊆ {1, 4, 6, 8, 9, 10}  Condition Satisfied


Hence, we can say if S1 ⊆ S2 is true (condition satisfied) then S¯2⊆S¯1 will also be true (condition will be
satisfied)

8. Show that S1 = S2 if and only if S1 ∪ S2 = S1 ∩ S2.


Answer:
The above statement gets valid when both sets are equal sets but may not be equivalent sets.
Equal Sets: When elements in the set S1 is identical to the elements in the set S2 in any order, and each set is subset
to each other & said to be equal. Which is represented below:

A ⊂ B and B ⊂ A ⟺ A = B

Example:
S1 = {1, 2, 3, 4, 5} and S2 = {5, 4, 3, 2, 1}
S1 ∪ S2 = {1, 2, 3, 4, 5} ∪ {5, 4, 3, 2, 1} = {1, 2, 3, 4, 5} 1
S1 ∩ S2 = {1, 2, 3, 4, 5} ∩ {5, 4, 3, 2, 1} = {1, 2, 3, 4, 5} 2
From 1 and 2 we can say S1 ∪ S2 = S1 ∩ S2
Hence, we can conclude S1 = S2.

1. How many substrings aab are in wwRw, where w = aabbab?


Answer:
Given w = aabbab
Hence wwRw = (w)(wR)(w) = (aabbab)(babbaa)(aabbab)
= aabbabbabbaaaabbab
So, there are 2 aab substrings in wwRw

2. Use induction on n to show that |un| = n |u| for all strings u and all n.
Answer:
un is n lots of u string concatenated into one string.
If we assume n = 1, |u1|=|u|=1|u|
Step of Induction:
Suppose |un| = n |u|
Then |un+1| = |un| + |u| (by cardinality string definition and un)
= n |u| + |u| (by inductive hypothesis)
= (n+1) |u| (by cardinality string definition)
|un+1| = (n+1) |u|
Therefore, |un| = n |u|

If we assume n = 0, |u0|= |λ| = 0 = 0 |u|

Hence for all strings u and all n: |un| = n |u|


3. The reverse of a string, introduced informally above, can be defined more precisely by the recursive rules
aR = a, (wa)R = awR, for all a ∈ Σ, w ∈ Σ*. Use this to prove that (uv)R = vRuR, for all u, v ∈ Σ+.
Answer:
Before we proceed, we would consider few definitions:
aR = a  string containing only one symbol
To elaborate the above statement:
Assume y string, which can be partitioned in to two substrings
Which is y = ay
yR = (ay)R
= yRa  (where |a| ≤ 1)
As per the induction theory (uv)R = vRuR, holds good for two strings u and v
Induction Steps: as per above definition we can say uv = auv
(auv)R = (uv)Ra
= vRuRa
(uv)Ra = vRuRa
Hence, we can prove: (uv)R = vRuR

4. Prove that (wR)R=w(wR)R=w for all w ∈ Σ*.


Answer:
Induction was used to prove the above.
Base Case: |w| = 0, then w = ε, and |εR|R = εR = ε
Induction Theory: (wR)R = w when |w| ≤ n
Induction Step:
If we assume |w| = n+1 then w = ua for some u ∈ Σ* and a ∈ Σ
(wR)R = ((ua)R) R
= (aRuR)R
= (uR)R(aR)R
= ua
=w
Hence, (wR)R = w

5. Let L = {ab, aa, baa}. Which of the following strings are in L*: abaabaaabaa, aaaabaaaa, baaaaabaaaab,
baaaaabaa? Which strings are in L4?
Answer:
The following were the strings in L4
aaaabaaaa, baaaaabaa

S-ar putea să vă placă și