C6-DMA-19-Assignment by Hlaoli
C6-DMA-19-Assignment by Hlaoli
Discrete Mathematics
Module Name Module Code C6-DMA-19
& Applications
Instructions
Eff Date: 09-08-2023
1. Write your answers in black or blue ink. Use pencil for drawing diagrams.
2. Answers should be written clearly following the order in the question paper.
3. All group members Student ID’s must be written on the answer sheet. Failure to do so will mean
that your work cannot be marked.
4. Answer ALL questions and read questions carefully.
5. For All true and false questions provide a justification for your response.
6. Answers should be clear and readable.
7. No Late Submissions allowed.
QP-ASR-001|Rev 001
Page 1 of 6
Question 1 [20 marks]
1. Directed Graph
2. Leaf Node
3. Rooted Tree
4. Joint Probability
6. Subgraph
7. Closed Walk
8. Weighted Graph
Eff Date: 09-08-2023
9. Sample Space
11. Forest
18. Language
19. Grammar
Page 2 of 6
Question 2 [10 marks]
a. Suppose 36% of families own a dog, 30% of families own a cat, and 22% of the families that have a
dog also have a cat. A family is chosen at random and found to have a cat. What is the probability
they also own a dog? (5)
b. Suppose 30% of the women in a class received an A on the test and 25% of the men received an A.
The class is 60% women. Given that a person chosen at random received an A, what is the
probability this person is a man? (5)
QP-ASR-001|Rev 001
c. A bag contains 3 red balls, 5 blue balls, and 2 green balls. If one ball is drawn at random, calculate
the following:
ii. If a red ball is drawn and not replaced, what is the probability of drawing another red ball? (3)
Page 3 of 6
Question 4 [10 marks]
Eff Date: 09-08-2023
a. Solve the Travelling Salesman Problem using Brute Force (Graph A). (5)
b. Solve the Travelling Salesman Problem using Nearest Neighbor and state the steps (Graph B). (5)
c. Implement Dijkstra’s algorithm to find the Shortest Path from A to D (Graph B). (3)
d. Use Prim’s algorithm to find the weight of the minimum spanning tree (Graph A). (2)
Page 4 of 6
GRAPH A GRAPH B
a. Determine whether the string/word ‘cbabbaa’ belongs to the language generated by the grammar
Eff Date: 09-08-2023
G = (Σ, T, S, P), where Σ = {a, b, c, A, B, C, S}, T = {a, b, c}, S is the starting symbol, and the production
rules are:
S → AB
A → Ca
B → Ba
B → Cb
B→b
C → cb
C → b. (4)
c. Let Σ = {x, y} and let L = {w ∈ Σ* | the third-from-last character of w is y}. Design an NFA for L. (5)
QP-ASR-001|Rev 001
d. Let Σ = {a, b} and let L = {baa}. Design a DFA for L. And draw the transition table.
(7)
a. What is the domain and range of the function g(n) = 3n2 – 2, for n = 0, 1, 2, 3? (4)
c. Find a7 for the recursive function generated from a sequence: 6, 15, 28, 45, … (2)
Page 5 of 6
QP-ASR-001|Rev 001 Eff Date: 09-08-2023
Page 6 of 6