COMP9020 – Foundations of Computer Science
FINAL Exam – Term 3 2022
From Question 1 to Question 4
With my own solution (might be incorrect)
Part 1
It seems that I can't prove this question perfectly.
It is confusing.
1.1
Question
Prove that for all m,n,p∈N :
If lcm(m,p)=lcm(n,p), then lcm(m+n,p)≤lcm(n,p).
I can't prove it because I think it is incorrect. lcm(m+n,p) should greater or equal lcm(n,p).
The counter example is in Part 1.2
1.2
Question
Find a counter example to show that it is not the case that for all m,n,p∈N :
If lcm(m,p)=lcm(n,p), then lcm(m+n,p)=lcm(n,p).
Assum:
- m=1
- n=4
- p=8
Then:
- lcm(m,p)=8
- lcm(n,p)=8
- lcm(m+n,p)=40
Therefore:
lcm(m+n,p)=lcm(n,p)
1.3
Question
Prove that for all m,n,p∈N :
If lcm(m,p)=lcm(n,p), then lcm(m+n,p)∣lcm(n,p).
Part 2
2.1
Question
Prove, or find a counter example to disprove, for all sets A, B, C:
A∩(B\C)C=(A∩C)∩(A∩BC)
Definition of \: A\B=A∩Bc:
A∩(B\C)C=A∩(B∩CC)C
De Morgan's, C over ∩: (A∩B)C=AC∩BC:
A∩(B∩CC)C=A∩(BC∪C)
Distributivity of ∩ over ∪: A∩(B∪C)=(A∩B)∪(A∩C):
A∩(BC∪C)=(A∩BC)∪(A∩C)
Therefore, it is incorrect.
2.2
Question
Let Σ = {0,1}.
Prove, or find a counter example to disprove that for all X,Y ⊆ Σ*:
(X∗Y)∗⊆(X∪Y)∗
Assum:
(X∗Y)∗=w1w2...wi
Every element wi=xi1xi2...xikyi
and it could also be that:
xi1xi2...xikyi=(xi∪∅)∗∪(∅∪yi)⊆(X∪Y)∗
Therefore, we could find that every element wi in string (X∗Y)∗ could be restructed by (X∪Y)∗.
Proved:
(X∗Y)∗⊆(X∪Y)∗
Part 3
Let F denote the set of all well-formed formulas. Define the relation R⊆F×F as follows:
(φ,ψ)∈R if and only if (φ→ψ) is satisfiable
3.1
Question
Prove that for all φ,ψ∈F,
If φ⊨ψ then (φ,ψ)∈R.
Because φ⊨ψ, when φ is true, the ψ is true.
φ→ψ=¬φ∨ψ
When φ=true, ¬φ∨ψ=true.
When φ=false, ¬φ∨ψ=true.
Because φ→ψ could be true, it means that φ→ψ is satisfiable.
Therefore, (φ,ψ)∈R.
3.2
Question
Prove or disprove:
R is reflexive
You may use the result of part (a) [without proof] if it helps
If we want to prove that R is reflexive, we should prove that for every element φ∈F, (φ,φ)∈R.
It is easy to find that:
When φ is true, φ is true.
It means that:
φ⊨φ
According to the result of part (a), if φ⊨φ then (φ,φ)∈R.
Therefore, we could prove that R is reflexive.
3.3
Question
Prove or disprove:
R is transitive
You may use the result of part (a) [without proof] if it helps
Assum:
- X⊨Y
- Y⊨Z
According to the result of part (a), we could find that:
(X,Y)∈R(Y,Z)∈R
Because X⊨Y, YmodelsZ, when X=true, we could find that Y=true and Z=true.
Therefore, we could find that X⊨Z.
According to the result of part (a), we could find that:
(X,Z)∈R
Because:
(X,Y)∈R(Y,Z)∈R(X,Z)∈R
We could prove that R is transitive.
Part 4
4.1
Question
Arrange the following functions in increasing order of asymptotic complexity (i.e. if f ∈ O(g) then f appears before g in the list
(For recursively defined functions, assume T(0) = T(1) = 1).
- T(n)=T(n/2)+log(n)
- T(n)=4T(n/4)+4n
- T(n)=T(n−2)+2n
- T(n)=T(n/3)+3n
- 3n2+2n−1
- n100+100n
-
T(n)=T(n/2)+log(n)
Use Main Theorem, we could find that:
a=1b=2f(n)=log(n)nlogba=nlog21=n0=1
Because f(n)=O(log(n))=O(nlog21log1(n)), we could prove that:
T(n)=O(nlog21log1+1(n))=O(log2(n)).
-
T(n)=4T(n/4)+4n
Use Main Theorem, we could find that:
a=4b=4f(n)=4nnlogba=nlog44=n1=n
Because f(n)=4n=O(n)=O(nlogbalog0(n)), we could prove that:
T(n)=O(nlogbalog0+1(n))=O(nlog(n)).
-
T(n)=T(n−2)+2n
Every time the n decrease by 2. Therefore, the recursion time is n/2.
Every recursion we have to execute 2n times.
Therefore, T(n)=2n×2n=O(n2).
-
T(n)=T(n/3)+3n
Use Main Theorem, we could find that:
a=1b=3f(n)=3nnlogba=nlog31=n0=1
Use Main Theorem Case 3, we could prove that:
T(n)=O(n0.5).
-
3n2+2n−1
We could find that:3n2+2n−1=O(n2/3)
-
n100+100n
We could find that: n100+100n=O(n+1/n)=O(n)
This is the list of functions:
- O(log2(n)): T(n)=T(n/2)+log(n)
- O(n1/2): T(n)=T(n/3)+3n
- O(n2/3): 3n2+2n−1
- O(n): n100+100n
- O(nlogn): T(n)=4T(n/4)+4n
- O(n2): T(n)=T(n−2)+2n
4.2
Question
Consider the function f:ℕ→ℕ defined as:
f(n)=3n+2 (if n is even)f(n)=n2 (if n is odd) Which of the following properties does f satisfy?
Select all that apply:
- f∘f (n) = (f(n))² for all n
- f(n) ∈ O(n²)
- f is injective
- f(n) ≤ f(n+2) for all n
- f is surjective
- f(n) ≤ f(n+1) for all n
- f(n) ∈ O(n)
Correct:
- f(n) ∈ O(n²)
- f is injective
- f(n) ≤ f(n+2) for all n