Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

COS3701 Exam Revision OCTNOV 2026 Questions & Answers Past Papers 2026

Rating
-
Sold
-
Pages
30
Grade
A+
Uploaded on
25-05-2026
Written in
2025/2026

This exam revision paper is more than just a set of questions and answers. It’s designed to help you understand how each answer is reached, so you’re not just memorising but actually learning the concepts behind them. The solutions are clear, accurate, and supported by reliable academic references. It also includes predicted questions that are likely to appear, giving you a practical sense of what to expect and how to approach them with confidence. Whether you’re revising last minute or using it to strengthen your understanding over time, it’s structured in a way that aligns with what examiners look for. The explanations are straightforward and focused, making it easier to follow and apply. If you take the time to work through it properly, achieving high grades is a realistic outcome.

Show more Read less
Institution
Course

Content preview


]]
‡ ⋆



COS3701: Theoretical Computer Science III

OCT/NOV Examination 2026 Preparation Guide

Covers Past Papers: Oct/Nov 2023 to Oct/Nov 2025


⋆ ⋄ ⋆ ⋄ ⋆ ⋄ ⋆ ⋄ ⋆

[ Computer Science — Automata & Formal Languages [




_ Exam Revision Guide


COS3701
Module Code:

Theoretical Computer Science III
Module Name:

Oct/Nov 2023 & Oct/Nov 2024
Papers Covered:

For Oct/Nov
Predictions:

80 per paper
Total Marks:

2 Hours
Duration:


Study the patterns. Understand the logic. Practise the diagrams.




‡ Exam Revision Notes | COS3701 | 2023–2026

,COS3701 | Exam Revision 2023–2025 Theoretical Computer Science III



PAPER 1 — OCTOBER/NOVEMBER 2024
University Examinations · 05 November 2024 · 80 Marks · 2 Hours
Examiner: DR Mokwana Internal Moderator: Dr TG Moape




Page 2 of 30 ‡

,COS3701 | Exam Revision 2023–2025 Theoretical Computer Science III



Question 1 [16 marks]


(a) [2 marks]


Question: Determine a regular expression for the language L over the alphabet {a, b}
that consists of all words that have at least one a but contain exactly one bb substring
(and no other bs appear consecutively). Example words: bba, aaabbaaa, aaaabbaaaaaa.
Non-examples: b, a, bab, ab, aaabbbb, abaaabaaaaa.


Answer:

 Key Concept
A regular expression describes a regular language using concatenation, union (+),
and Kleene star (∗ ). Key constraint here: exactly one bb, at least one a, no other
adjacent bs.


The language L requires:

• Exactly one occurrence of bb (no bbb, no two separate bb)
• At least one a somewhere in the word
• bs only appear as single b or in the single bb block

Structure: Any b outside the bb block must be isolated (i.e. single). Segments between as
can contain at most one b.

Single-b (non-consecutive) segments over a and b: (a+ b)∗ a∗ (never two consecutive bs).

Let SAFE = a∗ (ba+ )∗ be the pattern of as and isolated bs.

The full expression (one bb block, at least one a):



SAFE · bb · SAFE where at least one a appears in the whole word


Since the bb block itself has no a, the a must come from SAFE. Refined:



RE = a∗ (ba+ )∗ bb a∗ (ba+ )∗ + (a+ (ba+ )∗ )∗ bb a∗ (ba+ )∗


A clean single expression enforcing at least one a overall and exactly one bb:



a∗ (ba+ )∗ bb a+ (ba+ )∗ + a+ (ba+ )∗ bb a∗ (ba+ )∗


Page 3 of 30 ‡

,COS3701 | Exam Revision 2023–2025 Theoretical Computer Science III


Both alternatives ensure at least one a is present; the bb block is unique because SAFE never
allows two consecutive bs.

⋆ Exam Tip
Full marks usually require: (1) showing the bb block is isolated, (2) demonstrating at
least one a, and (3) ensuring no extra consecutive bs. Show your reasoning clearly.



(b) [4 marks]


Question: Design a Deterministic Finite Automaton (DFA) that recognises all words in
L as defined above.


Answer:

 Key Concept
A DFA has states, transitions on each symbol, one start state, and accept states. Every
input must lead to exactly one transition.


State design strategy:

• Track: (i) whether we have seen a bb, (ii) whether we have seen an a, (iii) how many con-
secutive bs we are currently reading, (iv) dead/trap state for invalid input.

States:


State Meaning

q0 Start: no a seen, no bb seen, no pending b
q1 No a seen, no bb seen, one b pending
q2 a seen, no bb yet, no pending b
q3 a seen, no bb yet, one b pending
q4 a seen (possibly), exactly one bb seen, no trailing b
q5 a seen, one bb seen, one b pending
DEAD Invalid (second bb or bbb)

Accept state: q4 (has seen at least one a and exactly one bb). Note: q5 is not accepting be-
cause a trailing b after bb is only ok if single — we accept when we confirm no more bb.

Key transitions:

a b
• q0 −
→ q2 ; q0 →
− q1


Page 4 of 30 ‡

,COS3701 | Exam Revision 2023–2025 Theoretical Computer Science III


b a
− DEAD (would be bb but no a yet);
• q1 → q1 −
→ q2
a b
→ q2 ;
• q2 − q2 →
− q3
b a
− q4 (bb found, a was already seen);
• q3 → q3 −
→ q2
a b
→ q4 ;
• q4 − q4 →
− q5
b a
− DEAD (second bb);
• q5 → q5 −
→ q4
a,b
• DEAD −−→ DEAD

⋆ Exam Tip
Draw the DFA clearly with arrows, label all transitions on each symbol, circle accept
states with double circles. A state diagram earns full marks; a transition table alone
may lose marks.



(c) [4 marks]


Question: Use Theorem 21 to develop a Context-Free Grammar (CFG) for the language
L.

Answer:

 Key Concept
Theorem 21 states that every regular language is context-free. A DFA/NFA can be
converted to a CFG: each state qi becomes a non-terminal Qi . For each transition
x
→ qj , add production Qi → x Qj . For each accept state qi , add Qi → Λ.
qi −


Using the DFA above and Theorem 21:




Q0 → a Q2 | b Q1

Q1 → a Q2

Q2 → a Q2 | b Q3 | Λ (if q2 could be accept, but it’s not — remove Λ)

Q3 → b Q4 | a Q2

Q4 → a Q4 | b Q5 | Λ (accept state)

Q5 → a Q4




Note: Q4 is the only accept state, so Q4 → Λ is the only Λ production. The start non-



Page 5 of 30 ‡

, COS3701 | Exam Revision 2023–2025 Theoretical Computer Science III


terminal is Q0 .


(d) [6 marks]


Question: Convert the following CFG to Chomsky Normal Form (CNF):


S → aXY | Y b, X → XZY Z | a, Y → bY | Λ, Z→a|Λ


Answer:

 Key Concept
Chomsky Normal Form (CNF): All productions are either A → BC (two non-
terminals) or A → a (one terminal). Steps: (1) Remove Λ-productions, (2) Remove unit
productions, (3) Break long productions, (4) Replace terminals in mixed rules.


Step 1 — Find nullable variables (Λ-producers):

• Y → Λ directly ⇒ Y is nullable
• Z → Λ directly ⇒ Z is nullable
• X → XZY Z: if Y, Z nullable then X → X · Λ · Λ · Z = XZ; further analysis: X → Λ
requires X itself to be nullable, but X → a is not nullable, so X is not nullable.
• S → Y b: since Y is nullable, S → b is added.

Step 2 — Remove Λ-productions (add substitution variants):


Y → bY | b | Λ ⇒ Y → bY | b (remove Λ, add b for when Y → Λ)


Z → a (remove Λ production)

S → aXY | aX | Y b | b (added aX for Y → Λ; added b for Y → Λ in Y b)

X → XZY Z | XZZ | XY Z | XZ | a (all combos of removing nullable Y, Z)


Step 3 — Remove unit productions: None remain after above.

Step 4 — Convert to CNF (introduce helper non-terminals for terminals & long
rules):

New non-terminals: Ta → a, Tb → b.




Page 6 of 30 ‡

Connected book

Written for

Institution
Course

Document information

Uploaded on
May 25, 2026
Number of pages
30
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$3.51
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
BeeNotes teachmetutor
Follow You need to be logged in order to follow users or courses
Sold
313
Member since
11 months
Number of followers
0
Documents
861
Last sold
5 days ago
BeeNotes

BeeNotes: Buzzing Brilliance for Your Studies Discover BeeNotes, where hard-working lecture notes fuel your academic success. Our clear, concise study materials simplify complex topics and help you ace exams. Join the hive and unlock your potential with BeeNotes today!

4.1

39 reviews

5
23
4
4
3
8
2
1
1
3

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions