cits2211 discrete structures semester 2, 2015 ......2nd semester 2015 examinations 13 9. (a)...

41
2nd SEMESTER 2015 EXAMINATIONS 1 CITS2211 Discrete Structures SEMESTER 2, 2015 EXAMINATIONS This paper contains: 18 pages (including title page) Time allowed: 2 hours 10 minutes Instructions The exam has 12 questions with a total value of 120. Answer all the questions in the spaces provided in the question booklet. Candidates may bring one A4 page of notes to the examination. These notes must be hand written, not photocopied or printed and may be written on both sides of one A4 page. The page can not be folded or have any attachments. Any notes that do not meet these conditions will be considered unauthorized material, and will be removed by the exam invigilators. Your notes page must be submitted with your exam paper at the end of the exam. replace this page with ocial cover page 1

Upload: others

Post on 18-Aug-2020

4 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 1

CITS2211 Discrete Structures

SEMESTER 2, 2015 EXAMINATIONS

This paper contains: 18 pages (including title page)Time allowed: 2 hours 10 minutes

Instructions

The exam has 12 questions with a total value of 120.Answer all the questions in the spaces provided in the question booklet.Candidates may bring one A4 page of notes to the examination. These

notes must be hand written, not photocopied or printed and may be writtenon both sides of one A4 page. The page can not be folded or have anyattachments. Any notes that do not meet these conditions will be consideredunauthorized material, and will be removed by the exam invigilators. Yournotes page must be submitted with your exam paper at the end of the exam.

replace this page with o�cial cover page 1

Page 2: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 2

replace this 2nd page with o�cial cover page 2

(that is, this page has been left blank)

Page 3: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 3

1. Express the following statements using propositional or predicate logic.State any assumptions you make.

(a) The set of rational numbers is countable but if the set of realnumbers is not countable then the set of irrational numbers is notcountable.

[2 marks]

(b) Any set is a subset of the union of itself with any other set.

[2 marks]

QUESTION 1 CONTINUES OVER THE PAGE

Page 4: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 4

(c) Not all Tasmanians have the same mother.

[3 marks]

(d) There are two natural numbers which give the same answer if youdivide the first by the second or the second by the first, but thereare another two natural numbers which do not.

[3 marks]

SEE OVER

Page 5: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 5

2. (a) Prove, or disprove, whether (P $ Q) ! (P _Q) is a tautology.

[5 marks]

(b) Prove, or disprove, that ¬((P _Q) ! R) is logically equivalent to(Q ^ ¬R) _ (P ^ ¬R).

[5 marks]

SEE OVER

Page 6: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 6

3. (a) In the Venn diagram below, shade in the region A4 (B � C).

A B

C

(b) Let A = {0, 1, {0, 1},?}, B = {{0, 1}, {0}, 1}. Write down thefollowing sets, using correct bracketing.

A \ B =

A [ B =

(c) State the general formula relating the number |A[B| to the num-bers |A|, |B|, and |A\B|. Then check that this formula is satisfiedfor the sets A and B of Part (b).

(d) For the sets A and B of Part (b), write down the following num-bers:

|P(A)| =

|A⇥ B| =.

[10 marks]

SEE OVER

Page 7: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 7

4. Give an example, with reasons for your answer, of a binary relation onZ that is:

(a) One to one

(b) Many to one

(c) Symmetric and transitive

(d) Transitive but not symmetric

(e) Not reflexive, transitive nor symmetric

[10 marks]

SEE OVER

Page 8: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 8

5. (a) Let g : P(N) ! N defined by g(A) = |A|. Is g injective? Surjec-tive? Bijective? Explain carefully your answer.

(b) Show that P(N0) is NOT countable.Hint: use a similar argument to Cantor’s diagonal.

[10 marks]

SEE OVER

Page 9: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 9

6. (a) How many passwords satisfy all of the following conditions:

• The length is between 8 and 9 characters.

• It must contain exactly 7 letters.

• The non-digit characters are upper case letters.

(b) Let S be the set of finite non-empty binary strings. Define therelation R on S by:xRy whenever x and y agree on their first and last digits (inother words the first digit of x is the same as the first digit of yand the last digit of x is the same as the last digit of y).

i. Show that R is an equivalence relation.

ii. What is the equivalence class of the string 0? Describe theequivalence classes of R. In particular, explain how manythere are.

[10 marks]

SEE OVER

Page 10: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 10

7. (a) Draw a non-deterministic finite state machine for alphabet {a, b}that recognises exactly all words which end in aaabbb.

[5 marks]

(b) Draw a deterministic finite state machine to recognize the samelanguage as in 7(a).

[5 marks]

SEE OVER

Page 11: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 11

8. (a) Give a regular expression for the language L of all strings of 0sand 1s where each 0 is immediately followed by (at least) twoconsecutive 1s.

[2 marks]

(b) Give a regular expression for the complimentary language to L

from question 8(a). That is, the set of strings from that alphabetwhich are not in L.

[2 marks]

Question 8 is CONTINUED OVER

Page 12: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 12

(c) Does the string 01110111 belong to the regular set (1⇤01)⇤(11+0⇤)?Justify your answer.

[2 marks]

(d) Let L ✓ {0, 1, 2, 3}⇤ be the language consisting of all strings suchas 010101232323 that have some number of 01 pairs followed bythe same number of 23 pairs. Prove that L is not a regular lan-guage.

[4 marks]

SEE OVER

Page 13: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 13

9. (a) Consider a project that is broken down in tasks with dependenciesand time to complete as follows:Task Hours to perform Pre-requisite tasksA 3 NoneB 1 AC 4 NoneD 3 BE 2 A,CF 2 EG 4 D,FH 3 FI 1 HJ 3 G,I

i. Construct a PERT chart for this process.

ii. Determine the minimum time-to-completion for this process.

iii. Determine a critical path and a topological sort for this pro-cess.

(b) Show that, for an integer n, if n2 is a multiple of 5, then n is amultiple of 5.[4 marks]

[10 marks]

SEE OVER

Page 14: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 14

10. (a) Prove, using the pigeonhole principle or otherwise that: if eachpoint of the Euclidean space R3 is coloured red, green, or blue,then there are two points of the same colour at distance 1cm fromeach other.

(b) Given a group of 250 people, at minimum, how many people wereborn during the month when the most people in the group wereborn?

(c) Show that 11n + 4 is divisible by 5 for all positive integers n.

[10 marks]

SEE OVER

Page 15: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 15

11. (a) Give a brief but careful explanation of what the halting problemis.

[4 marks]

Question 11 is CONTINUED OVER

Page 16: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 16

(b) Outline a procedure that could be used by a Turing Machine torecognize the following language L from the alphabet {0, 1}. L

contains exactly the sequences of 0s and 1s which contain thesame number of 0s as 1s in any order.

You do not have to give a formal specification of the machine’smoves, but explain the algorithm in terms of the series of stepsthe machine would use for this calculation.

[6 marks]

SEE OVER

Page 17: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 17

12. (a) Define a grammar that generates the language 0⇤1(01)⇤. Justifyyour answer.

[5 marks]

(b) Can you define a context-free grammar that generates the lan-guage 0⇤1(01)⇤ (from Question 12(a))? Justify your answer.

[5 marks]

END OF PAPER

Page 18: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 18

Blank page for extra writing if needed

Page 19: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 1

CITS2211 Discrete Structures

SEMESTER 2, 2015 EXAMINATIONS

This paper contains: 18 pages (including title page)Time allowed: 2 hours 10 minutes

InstructionsThe exam has 12 questions with a total value of 120.Answer all the questions in the spaces provided in the question booklet.Candidates may bring one A4 page of notes to the examination. These

notes must be hand written, not photocopied or printed and may be writtenon both sides of one A4 page. The page can not be folded or have anyattachments. Any notes that do not meet these conditions will be consideredunauthorized material, and will be removed by the exam invigilators. Yournotes page must be submitted with your exam paper at the end of the exam.

replace this page with o�cial cover page 1

Page 20: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 2

replace this 2nd page with o�cial cover page 2

(that is, this page has been left blank)

Page 21: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 3

1. Express the following statements using propositional or predicate logic.State any assumptions you make.

(a) The set of rational numbers is countable but if the set of realnumbers is not countable then the set of irrational numbers is notcountable.

Solution: Put

QC = the set of rational numbers is countable

RC = the set of real numbers is countable

IC = the set of irrational numbers is countable

Then we have QC ^ (¬RC ! ¬IC)

[2 marks]

(b) Any set is a subset of the union of itself with any other set.

Solution:

Suppose that we quantify over a set of sets.

Then we have 8S.8R.(S ✓ S [R)

[2 marks]

QUESTION 1 CONTINUES OVER THE PAGE

Page 22: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 4

(c) Not all Tasmanians have the same mother.

Solution:

Quantify over all Australians.

T (t) means t is a Tasmanian.

M(m, t) means that m is the mother of t.

Then we have ¬9m.8t.(T (t) ! M(m, t))

[3 marks]

(d) There are two natural numbers which give the same answer if youdivide the first by the second or the second by the first, but thereare another two natural numbers which do not.

Solution:

Quantify over all natural numbers.

Then we have (9x.9y.(x/y = y/x)) ^ (9x.9y.¬(x/y = y/x))

[3 marks]

SEE OVER

Page 23: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 5

2. (a) Prove, or disprove, whether (P $ Q) ! (P _Q) is a tautology.

Solution: Use a truth table.

P Q P $ Q P _Q (P $ Q) ! (P _Q)T T T T TT F F T TF T F T TF F T F F

As the proposition is not always true (last column) it is not atautology.

[5 marks]

(b) Prove, or disprove, that ¬((P _Q) ! R) is logically equivalent to(Q ^ ¬R) _ (P ^ ¬R).

Solution: Easier to use equivalence rules here.

LHS ⌘ ¬((P _Q) ! R)⌘ ¬(¬(P _Q) _R) equivalence for implication⌘ ¬¬(P _Q) ^ ¬R De Morgan⌘ (P _Q) ^ ¬R) Double negation⌘ (Q _ P ) ^ ¬R) communtivity of or⌘ (Q ^ ¬R) _ (P ^ ¬R) Distribution⌘ RHS

As required. They are logically equivalent.

[5 marks]

SEE OVER

Page 24: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 6

3. (a) In the Venn diagram below, shade in the region A4 (B � C).

A B

C

Solution:

A B

C2�

(b) Let A = {0, 1, {0, 1},?}, B = {{0, 1}, {0}, 1}. Write down thefollowing sets, using correct bracketing.

A \ B =

A [ B =

Solution: A \ B = {1, {0, 1}} 1�A [ B = {0, 1, {0, 1},?, {0}} 1�

(c) State the general formula relating the number |A[B| to the num-bers |A|, |B|, and |A\B|. Then check that this formula is satisfiedfor the sets A and B of Part (b).

Solution: We have seen the formula: |A [ B| = |A|+ |B|�|A \ B| 1�.

Page 25: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 7

Here |A| = 3, |B| = 4 1� , |A [ B| = 5 |A \ B| = 2 1�,so indeed we have 5 = 3 + 4� 2 1�.

(d) For the sets A and B of Part (b), write down the following num-bers:

|P(A)| =

|A⇥ B| =.

Solution:

|P(A)| = 24 = 16 since |A| = 4 1�|A⇥ B| = 4 ⇤ 3 = 12 since |A| = 4 and |B| = 3 1�.

[10 marks]

SEE OVER

Page 26: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 8

4. Give an example, with reasons for your answer, of a binary relation onZ that is:

(a) One to one

Solution: {(x,�x) : x 2 Z}. Each element in the domainis related to only one element in the codomain, its opposite,and vice-versa. (Equality works too, even easier) 2�

(b) Many to one

Solution: {(x, x2) : x 2 Z}. Each element in the domainis related to only one element in the codomain, its square,but the positive integers in the codomain are related to twoelements in the domain. 2�

(c) Symmetric and transitive

Solution: For instance equivalence relations work. Equiva-lence relations that we have seen:Equality {(x, x) : x 2 Z} or{(x, y) 2 Z⇥ Z : |x| = |y|}

or any example with justifications. 2�

(d) Transitive but not symmetric

Solution: For instance partial orders work. {(x, y) 2 Z⇥Z :x y}. 1 2 but 2 6 1. Transitive: a b and b c impliesa c.

or any example with justifications. 2�

(e) Not reflexive, transitive nor symmetric

Solution: Probably the hardest.R = {(0, 1), (0, 2), (2, 0)}Not reflexive: (0, 0) /2 R,

Page 27: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 9

Not symmetric: (0, 1) 2 R but (1, 0) /2 RNot transitive: (0, 2), (2, 0) 2 R but (0, 0) /2 R

Other example: {(x, x2) : x 2 Z}Not reflexive: (2, 2) /2 R,Not symmetric: (2, 4) 2 R but (4, 2) /2 RNot transitive: (2, 4), (4, 16) 2 R but (2, 16) /2 R

2�

[10 marks]

SEE OVER

Page 28: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 10

5. (a) Let g : P(N) ! N defined by g(A) = |A|. Is g injective? Surjec-tive? Bijective? Explain carefully your answer.

Solution: It is NOT injective: g({1}) = g({2}) 1�.It is surjective. Let n 2 N. If n = 0 then g(;) = n. Otherwiseg({1, 2, . . . , n}) = n 2�.It is not injective so not bijective 1�.

(b) Show that P(N0) is NOT countable.Hint: use a similar argument to Cantor’s diagonal.

Solution: Assume, as a thought experiment, that there is abijection f from N0 to P(N0).

So f(1), f(2), f(3), . . . , f(n), . . . are all subsets of N0.

We will construct a subset A that is not the image of anyinteger.

If 1 2 f(1) set 1 /2 A, while if 1 /2 f(1) set 1 2 A.If 2 2 f(2) set 2 /2 A, while if 2 /2 f(2) set 2 2 A.In generalIf n 2 f(n) set n /2 A, while if n /2 f(n) set n 2 A.In other words A = {a 2 N0|a /2 f(a)}.Now A 6= f(1) since A and f(1) di↵er in membership of 1.A 6= f(2) since A and f(2) di↵er in membership of 2.In generalA 6= f(n) since A and f(n) di↵er in membership of n.

Therefore f is not surjective, a contradiction.

Hence there is no bijection and P(N0) is not countable.

They can also explain it using infinite binary string, which isequivalent. 6�

[10 marks]

SEE OVER

Page 29: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 11

6. (a) How many passwords satisfy all of the following conditions:

• The length is between 8 and 9 characters.

• It must contain exactly 7 letters.

• The non-digit characters are upper case letters.

Solution: We do separately the cases 8 and 9 characters1�.For 8 characters: we have either 7 letters (8 choices for theposition of the digit). So the number is 8 ⇤ 267 ⇤ 10 1�For 9 characters: we have 7 letters (36 choices for the positionof the two digits). So the number is 36 ⇤ 267 ⇤ 102 1�So in total: 8 ⇤ 267 ⇤ 10 + 36 ⇤ 267 ⇤ 102 1�(all quite straigthforward except for 7 letters among 9 charac-ters)

(b) Let S be the set of finite non-empty binary strings. Define therelation R on S by:xRy whenever x and y agree on their first and last digits (inother words the first digit of x is the same as the first digit of yand the last digit of x is the same as the last digit of y).

i. Show that R is an equivalence relation.

Solution: REFLEXIVE x agrees with itself on its firstand last digits (on all its digits actually), so xRx. 1�SYMMETRIC Assume xRy. Then x and y agree on theirfirst and last digits, so y and x agree on their first andlast digits. Thus yRx. 1�TRANSITIVE Assume xRy and yRz. Then x and y agreeon their first and last digits, and so do y and z. Hence xand y agree on their first and last digits, and so xRz. 1�

ii. What is the equivalence class of the string 0? Describe theequivalence classes of R. In particular, explain how manythere are.

Solution: The equivalence class of the string 0 is theset of all strings that start and finish with a 0. 1�

Page 30: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 12

In general [x]R consists of all the strings that start withthe first digit of x and finish with the last digit of x. 1�Hence there are four classes: [0]R = [00]R, [1]R =[11]R, [01]R, [10]R 1�

[10 marks]

SEE OVER

Page 31: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 13

7. (a) Draw a non-deterministic finite state machine for alphabet {a, b}that recognises exactly all words which end in aaabbb.

Solution:

// 1

a,b

⌦⌦a // 2

a // 3a // 4

b // 5b // 6

b // 7

[5 marks]

(b) Draw a deterministic finite state machine to recognize the samelanguage as in 7(a).

Solution:

17

b{{

a

⇧⇧

// 1

b

⌦⌦

a✏✏

16

b

OO

a{{

12

b

OO

a✏✏

15

b

OO

aoo

123a //

b

GG

1234

b

OO

aTT

[5 marks]

SEE OVER

Page 32: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 14

8. (a) Give a regular expression for the language L of all strings of 0sand 1s where each 0 is immediately followed by (at least) twoconsecutive 1s.

Solution:

(1 + (011))⇤

[2 marks]

(b) Give a regular expression for the complimentary language to Lfrom question 8(a). That is, the set of strings from that alphabetwhich are not in L.

Solution:

((0 + 1)⇤(0 + 01)) + ((0 + 1)⇤(00 + 010)(0 + 1)⇤)

[2 marks]

Question 8 is CONTINUED OVER

Page 33: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 15

(c) Does the string 01110111 belong to the regular set (1⇤01)⇤(11+0⇤)?Justify your answer.

Solution:

Yes.

Say, a = 01 and b = 11.

Then a matches (1⇤01) (with no repeats of 1).

Also ba matches (1⇤01).

Thus aba matches (1⇤01)⇤.

Also b matches 11 so b matches (11 + 0⇤).

So 01110111 = abab matches (1⇤01)⇤(11 + 0⇤).

[2 marks]

(d) Let L ✓ {0, 1, 2, 3}⇤ be the language consisting of all strings suchas 010101232323 that have some number of 01 pairs followed bythe same number of 23 pairs. Prove that L is not a regular lan-guage.

Solution: Suppose L is regular, and that it has pumpinglength p. Select w = (01)p(23)p. Clearly w 2 L. By the pump-ing lemma, there is xyz = w satisfying its stated propertiesincluding |xy| p. For any such choice x and y must consistonly in 0s and 1s.

Now, the pumping lemma states that xyyz 2 L but we knowxyyz /2 L because that has more 01s than 23s.

Therefore, L is not regular. QED

[4 marks]

SEE OVER

Page 34: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 16

9. (a) Consider a project that is broken down in tasks with dependenciesand time to complete as follows:Task Hours to perform Pre-requisite tasksA 3 NoneB 1 AC 4 NoneD 3 BE 2 A,CF 2 EG 4 D,FH 3 FI 1 HJ 3 G,I

i. Construct a PERT chart for this process.

Solution: 3�

A

B

C

D

E F

G

H I

J

ii. Determine the minimum time-to-completion for this process.

Solution: The minimum time-to-completion is 15 hours1� as shown in this diagram:

A

B

C

D

E F

G

H I

J

0, 3, 4

3, 1, 4

0, 4, 4

4, 3, 7

4, 2, 6 6, 2, 8

8, 4, 12

8, 3, 11 11, 1, 12

12, 3, 15

iii. Determine a critical path and a topological sort for this pro-cess.

Solution: There are 2 critical paths (we only ask oneof them): C,E,F,G,J and C,E,F, H, I ,J. 1�

Page 35: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 17

A topological sort is for instance: A,C,B,E,D,F,G,H,I,J1�

(b) Show that, for an integer n, if n2 is a multiple of 5, then n is amultiple of 5.[4 marks]

Solution: We choose to prove the contrapositive, namelythat “n not a multiple of 5 implies that n2 is not a multiple of5”.

Let n be an integer that is not a multiple of 5 (Assumption)Then n = 5k + a for some integer k and some a 2 {1, 2, 3, 4}(Defn. of multiple)Then n2 = 25k2 + 10ak + a2 (Arithmetic)Then n2 = 5(5k2 + 2ak) + a2 (Arithmetic)Then n2 = 5k0 + a2 where k0 = 5k2 + 2ak is an integer anda2 2 {1, 4, 9, 16} (Arithmetic)Therefore n2 is not a multiple of 5 (Defn. of multiple)

[10 marks]

SEE OVER

Page 36: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 18

10. (a) Prove, using the pigeonhole principle or otherwise that: if eachpoint of the Euclidean space R3 is coloured red, green, or blue,then there are two points of the same colour at distance 1cm fromeach other.

Solution: Consider a regular tetrahedron of side length 1cm.It has 4 vertices, coloured with only 3 colours. By the pigeon-hole principle, two of these vertices will have the same colour,and by construction, these two points are at distance 1cm. 3�

(b) Given a group of 250 people, at minimum, how many people wereborn during the month when the most people in the group wereborn?

Solution: This is the generalised version of the pigeon holeprinciple. On average there are 250/12 ⇡ 20.83 people permonth. At minimun 21 people were born during the “bestmonth”. 2�

(c) Show that 11n + 4 is divisible by 5 for all positive integers n.

Solution: We use induction to prove the statement

P (n) : 5 | (11n + 4)

The base case If n = 1, then 11n+4 = 15, which is divisibleby 5, so P (1) is true. 1�The Inductive Step Assume that P (k) is true, and do somearithmetic as follows: 11k+1 + 4 = 11(11k) + 4 1�Now, by the inductive hypothesis, 5 | 11k + 4, and so 11k =5m� 4 for some integer m 1�.

Then 11k+1+4 = 11(5m�4)+4 = 55m�44+4 = 5(m�8) 1�and we have proved P (k + 1).

Therefore P (k) ! P (k + 1) and so by the PMI, P (n) holdsfor all n 2 N0. 1�

[10 marks]

Page 37: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 19

SEE OVER

Page 38: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 20

11. (a) Give a brief but careful explanation of what the halting problemis.

Solution:

the famous Halting problem:

Is there an algorithm that given a string sT represent-ing a Turing machine T , and an input string ↵ candetermine whether T will halt if it is given the string↵ as input?

The answer is that there can be no such algorithm and hencethe Halting Problem is formally unsolvable.

[4 marks]

Question 11 is CONTINUED OVER

Page 39: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 21

(b) Outline a procedure that could be used by a Turing Machine torecognize the following language L from the alphabet {0, 1}. Lcontains exactly the sequences of 0s and 1s which contain thesame number of 0s as 1s in any order.

You do not have to give a formal specification of the machine’smoves, but explain the algorithm in terms of the series of stepsthe machine would use for this calculation.

Solution:

There are many ways to do this. Full marks for a correct wayexplained in su�cient detail.

Suppose the string’s left end is under the head initially and isended by a space character on the right. We will assume 0, 1and space are in the working alphabet.

The TM starts at the initial tape square and repeats a proce-dure A until a halt condition. Then it moves on to procedureB.

Procedure A is as follows, starting at the left end of the string.If there is a space under the head then halt and accept thestring.

We repeatedly move back and forwards along the tape fromleft end to right end. If a 1 is seen just to the left of a 0 thenswap them and continue.

When there are no swaps to do from one end to the other thenend procedure A. The symbols in the string are sorted.

Procedure B consists in going from end to end in the string,replacing a 0 on the left by a space and a 1 on the right.

If we erase the whole string then we accept the input.

Otherwise, if there are symbols left, we reject it.

[6 marks]

SEE OVER

Page 40: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 22

12. (a) Define a grammar that generates the language 0⇤1(01)⇤. Justifyyour answer.

Solution:

S ! A1BA ! �A ! 0AB ! �B ! 01B

Each A will be expanded into a sequence of 0s and each B intoa sequence of 01s.

[5 marks]

(b) Can you define a context-free grammar that generates the lan-guage 0⇤1(01)⇤ (from Question 12(a))? Justify your answer.

Solution:

Yes. We need only get rid of the extra erasing productions.Here ...

S ! 1S ! A1S ! 1BS ! A1BA ! 0A ! 0AB ! 01B ! 01B

This is context-free as it obeys the erasing convention (in factno erasing productions) and productions start from single non-terminals.

In fact, we can define a regular grammar even.

[5 marks]

END OF PAPER

Page 41: CITS2211 Discrete Structures SEMESTER 2, 2015 ......2nd SEMESTER 2015 EXAMINATIONS 13 9. (a) Consider a project that is broken down in tasks with dependencies and time to complete

2nd SEMESTER 2015 EXAMINATIONS 23

Blank page for extra writing if needed