0% found this document useful (0 votes)
4 views

Comp Sci analysis Assignment4-Solutions

The document contains a homework assignment for a course on Analysis of Algorithms, detailing problems related to recursive functions and mathematical proofs. It includes specific questions about deriving recurrence relations, proving integer properties, and simplifying expressions under certain conditions. The assignment is due on February 14, 2025, and consists of multiple parts with solutions provided for each question.

Uploaded by

aignue
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Comp Sci analysis Assignment4-Solutions

The document contains a homework assignment for a course on Analysis of Algorithms, detailing problems related to recursive functions and mathematical proofs. It includes specific questions about deriving recurrence relations, proving integer properties, and simplifying expressions under certain conditions. The assignment is due on February 14, 2025, and consists of multiple parts with solutions provided for each question.

Uploaded by

aignue
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Homework Assignment 4

due Friday, February 14, 2025, 11:59pm


SOLUTIONS

a
1. This question refers to the following code. Assume that the / symbol represents integer division: a/b = b .
Let A be an integer array.

1 // pre: (A.length >= 1) ∧ (0 <= low,high < A.length)


2 void recursiveFnc(int[] A, int low, int high)
3 if (low < high-5)
4 localFnc(A, low, high)
5 recursiveFnc(A, (5*low+high)/6 + 1, (low+high)/2)
6 recursiveFnc(A, (2*low+high)/3 + 1, (low+2*high)/3)

Let n = high − low + 1. Assume that localFnc(A, low, high) performs some operation on the entries
A[low], . . ., A[high] inclusive, and that if this function acts on n entries, its cost is n2 .

(5 marks) (a) Let T (n) be the cost of recursiveFnc() as a function of the input size n. Find the recurrence relation
that defines T (n), and show your work.
You will need to use the floor and/or ceiling functions. The only variable should be n: the indices low
and high should not appear in your final answer. Once you have eliminated low and high in favor of n,
you do not need to simplify your expressions any further.

Solution: We have n = high − low + 1. The recursive case occurs when low < high − 5, or
equivalently, when n = high − low + 1 > 6. The base cases occur when n ≤ 6. In the base cases,
the function takes 1 step to check the if condition on line 3.
Let the size of the inputs in line 5 and 6 be A and B, respectively. In the recursive case, the function
takes 1 step to check the if condition on line 3, then n2 steps to execute line 4, then T (A) steps to
execute line 5, then T (B) steps to execute line 6. This gives a total of T (A) + T (B) + n2 + 1.
Therefore the cost function T (n) satisfies a recurrence relation with the following form:
§
1, n≤6
T (n) =
T (A) + T (B) + n2 + 1, n>6

It remains to determine A and B.


Using the substitution high = n + low − 1, the input size A can be written as
low + high 5 ∗ low + high
› ž › ž ‹
A = − +1 +1
2 6
low + high 5 ∗ low + high
› ž › ž
= −
2 6
low + n + low − 1 5 ∗ low + n + low − 1
› ž › ž
= −
2 6
n−1 n−1
› ž › ž
= low + − low −
2 6
n−1 n−1
› ž › ž
= − .
2 6

COMP 2080: Analysis of Algorithms (Winter 2025) Page 1 of 13


Similarly, the input size B can be written as
low + 2 ∗ high 2 ∗ low + high
› ž › ž ‹
B = − +1 +1
3 3
low + 2 ∗ high 2 ∗ low + high
› ž › ž
= −
3 3
low + 2(n + low − 1) 2 ∗ low + n + low − 1
› ž › ž
= −
3 3
2n − 2 n−1
› ž › ž
= low + − low −
3 3
2n − 2 n−1
› ž › ž
= − ,
3 3

COMP 2080: Analysis of Algorithms (Winter 2025) Page 2 of 13


(2 marks) (b) Prove the following statement:
3r − 1 3s − 3
for all integers r, s, if r, s ≥ 1, then is an integer, and is an integer.
2 6
Hint: you may use the Fundamental Theorem of Arithmetic, i.e., every integer greater than 1 can be written
exactly one way as a product of prime numbers (ignoring the ordering of the factors).
SOLUTION 1: using the hint

Solution:

(1) Consider arbitrary integer r, s ≥ 1.

(2) First, we prove that (3 r − 1)/2 is an integer.

(3) The integer 3 r can be written as a product of r 3’s. By the Fundamental Theorem of
Arithmetic, the integer 3 r cannot be written as a product containing the prime factor 2, which
implies that 3 r is not divisible by 2.

(4) Since 3 r is not divisible by 2, it is odd. Subtracting 1 from an odd number yields an even
number, so 3 r − 1 is even, and it follows that (3 r − 1)/2 is an integer, as desired.

(5) Next, we prove that (3s − 3)/6 is an integer. We give a proof by cases.

(6) In the case s = 1, we see that 3s − 3 = 3 − 3 = 0, so (3s − 3)/6 = 0/6 = 0 is an integer, as


desired.

(7) In the case s ≥ 2, observe that (3s − 3)/6 = 3(3s−1 − 1)/6 = (3s−1 − 1)/2.

(8) Since s − 1 ≥ 1, we can apply our result from step (4) with r = s − 1 to conclude that
(3s−1 − 1)/2 is an integer.

(9) From the outcomes of the previous two steps, we have shown that (3s − 3)/6 = (3s−1 − 1)/2 is
an integer, as desired.

(10) We have considered all possible cases since every integer s ≥ 1 is either equal to 1 or is at least
2. So we proved that (3s − 3)/6 is an integer in all cases, which completes the proof.

SOLUTION 2: ignoring the hint

Solution:

(1) Consider arbitrary integer r, s ≥ 1.

(2) Let P(r) be the predicate: (3 r − 1)/2 is an integer. We prove that P(r) is true for all r ≥ 1 by
induction on r.

(3) Base Case: Consider r = 1. Then (3 r − 1)/2 = (3 − 1)/2 = 2/2 = 1, which is an integer.

(4) Induction Hypothesis: For some r ≥ 2, assume that P(1) ∧ · · · ∧ P(r − 1) is true.

COMP 2080: Analysis of Algorithms (Winter 2025) Page 3 of 13


(5) Inductive Step: note that

3r − 1 3r − 3 + 2
=
2 2
3(3 r−1 − 1) + 2
=
2
(3 r−1 − 1)
=3· +1
2
= 3k + 1 for some integer k, by the induction hypothesis

∈ Z since multiplying and adding integers results in an integer

(6) This completes the inductive step, which completes the proof that (3 r − 1)/2 is an integer.

(7) See Solution 1 for proof that (3s − 3)/6 is an integer.

COMP 2080: Analysis of Algorithms (Winter 2025) Page 4 of 13


(3 marks) (c) In the special case where n = 3 r for some integer r ≥ 0, prove that your recurrence relation from part
(a) can be simplified to the following form:

d, n≤c
T (n) = n

aT b + f (n), n > c

You may use the fact stated in part (b) in your proof.

Solution: Assume that n = 3 r for some integer r ≥ 0. From part (b), we know that the quantities
n−1 n−3
2 and 6 are both integers under our assumption about n.
Using these properties of n, the expression A can be simplified as
n−1 n−1
› ž › ž
A = −
2 6
n−1 n−3+2
› ž
= −
2 6
n−1 n−3 1
 › ž‹
= − +
2 6 3
n−1 n−3
= −
2 6
n
= .
3
Similarly, B can be simplified as
2n − 2 n−1
› ž › ž
B = −
3 3
2n 2 1
› ž  › ž‹
n
= + − − + −
3 3 3 3
2n n
= −1− +1
3 3
n
= .
3
Note that n = 1 and n = 3 both correspond to base cases, and the recursion case occurs when n ≥ 9.
Consequently, the expression 3n is guaranteed to be an integer when it appears in the input sizes A
and B.
Thus, in the special case where n is a power of 3, the recurrence relation from (a) simplifies to

1, n≤6
T (n) = n

2T 3 + n + 1, n > 6
2

2. This question refers to the following recurrence relation.



 1, n=1
T (n) = 4, n=2
 T (n − 2) + n2 , n>2

(6 marks) (a) Use the substitution method to derive a closed-form expression for this recurrence relation. Consider
the case where n is even only. You do not need to repeat your calculation for the case where n is odd.
Simplify your answer until no summation notation remains.

COMP 2080: Analysis of Algorithms (Winter 2025) Page 5 of 13


Solution: Assume that n is an even number. By repeated substitution, we get
T (n) = T (n − 2) + n2

= T (n − 4) + (n − 2)2 + n2

= T (n − 6) + (n − 4)2 + (n − 2)2 + n2

= ...
After j substitutions, we guess that
j−1
X
T (n) = T (n − 2 j) + (n − 2k)2 .
k=0

Since n is even, n − 2, n − 4, . . . are also even numbers. The process ends when n − 2 j, the value
passed to T (), is one of the base cases. The even base case is n = 2, so the substitution process ends
when n − 2 j = 2, which occurs when j = 2n − 1. With this substitution,
n/2−2
X n/2−2
X
T (n) = T (2) + (n − 2k) = 4 +
2
(n − 2k)2 .
k=0 k=0

There are a few ways to evaluate this expression. One is by brute force:
n/2−2
X n/2−2
X 
4+ (n − 2k)2 = 4 + n2 − 4nk + 4k2
k=0 k=0

n/2−2
X n/2−2
X n/2−2
X
= 4 + n2 1 − 4n k+4 k2
k=0 k=0 k=0

Using three given summation identities,


n  1 n n  1 n n 
= 4 + n2 − 1 − 4n · −2 −1 +4· −2 − 1 (n − 3)
2 2 2 2 6 2 2
• 1 n 1 n
n     ˜
= 4+ − 1 n2 − 4n · −2 +4· − 2 (n − 3)
2 2 2 6 2
n−2  1
 ‹• ˜
= 4+ n2 − n2 − 4n + (2n − 8) (n − 3)
2 6
n−2 1
 ‹• ˜
= 4+ 4n + 2n2 − 14n + 24
2 6

24n + 2n2 − 14n + 24


‹ 
n−2

= 4+
2 6

48 + (n − 2)(10n + 2n2 + 24)


=
12
48 + 10n2 + 2n3 + 24n − (20n + 4n2 + 48)
=
12
6n2 + 2n3 + 4n
=
12
2n(3n + n2 + 2)
=
12
n(n + 1)(n + 2)
=
6

COMP 2080: Analysis of Algorithms (Winter 2025) Page 6 of 13


Alternatively, a trick is to use the fact that n − 2k is even, i.e., n − 2k = 2m for some integer m.
Replace n − 2k with 2m, and now compute the sum over m. To compute lower and upper limits
of the summation, use the relationship n − 2k = 2m: when k = 0 we see that m = 2n , and when
k = 2n − 2 we see that m = 2. Therefore,
n/2−2
X Xn/2
4+ (n − 2k)2 = 4 + (2m)2
k=0 m=2

n/2
X
= (2m)2
m=1

n/2
X
= 4 m2
m=1

1 n n 
= 4· · + 1 (n + 1) (using summation identity)
6 2 2
n(n + 1)(n + 2)
= .
6

COMP 2080: Analysis of Algorithms (Winter 2025) Page 7 of 13


(4 marks) (b) Prove that your closed-form expression in part (a) is correct for all n ≥ 1 using mathematical induction.

Solution:
(1) Let P(n) be the statement T (n) = 16 n(n + 1)(n + 2). We will show that P(n) is true for all n ≥ 1.

(2) Base cases. When n = 1, we have T (1) = 1 from the recurrence relation, and 16 n(n+1)(n+2) = 1.
Thus P(1) is true.

When n = 2, we have T (2) = 4 from the recurrence relation, and 16 n(n + 1)(n + 2) = 4. Thus P(2) is
also true.

(3) Induction step. Let n > 2 be arbitrary, and assume that T (k) = 16 k(k + 1)(k + 2) for all k < n.
We will show that T (n) = 61 n(n + 1)(n + 2).

(4) Using the recurrence relation, we have


T (n) = T (n − 2) + n2
(n − 2)(n − 1)n
= + n2 by induction hypothesis
6
n 2 
= n − 3n + 2 + 6n
6
n 2 
= n + 3n + 2
6
n(n + 1)(n + 2)
= ,
6
as needed.

COMP 2080: Analysis of Algorithms (Winter 2025) Page 8 of 13


3. This question refers to the following recurrence relation. You should assume that n is a power of 9.

1, n≤9
T (n) = p
3T 9n + 2 n, n > 9


(6 marks) (a) Draw the recursion tree for the recurrence relation. Include at least three rows of the tree. Calculate the
sum of each row, and then derive an expression for the sum of all entries in the tree. Use the result to
conjecture a function g(n) so that T (n) ∈ Θ(g(n)).
You should remove unnecessary constants and additive terms from your g(n), that is: if you have an
expression g1 (n), and you can obtain an expression g2 (n) by deleting some constants and additive terms
from g1 such that g2 (n) = Θ(g1 (n)), then you should use g2 (n) for your answer.

Solution:
Row Sums

p p
row 1 2 n 2 n

p
2 9n
Æ Æn Æn
row 2 2 9 2 9 2 n

Æ n
Æ n
Æ n
Æ n
Æ n
Æ n
Æ n
Æ n
Æ n p
row 3 2 81 2 81 2 81 2 81 2 81 2 81 2 81 2 81 2 81 2 n

...
Since n is a power of 9, the recursion ends once the input size has been reduced to a power of 9 that
corresponds to a base case. The first such value is 9.
n
Using the labeling of row numbers shown above in the diagram, the input size in row j is j−1 , and
9
the last row occurs when n/9 j−1 = 9. Solving for j: we see that n = 9 j , so j = log9 n.
p
Therefore, there are log9 n rows, each row sum is 2 n, so the total cost over the entire tree is
p
2 n log9 n.
p
We use this result to conjecture that T (n) ∈ Θ( n log n).

(2 marks) (b) Explain which case of the Master Theorem applies to the recurrence relation, and use that case to prove
your conjecture from part (a).

Solution: We demonstrate that Case 2 of the Master Theorem applies.


p
From the given T (n), we see that a = 3, b = 9, f (n) = 2 n. Computing log b a = log9 3 = 1/2, we
p
see that nlog b a
= n . We observe that f (n) = 2 n = 2n1/2 ∈ Θ(n1/2 ) = Θ(nlog b a ), so we conclude
1/2

that Case 2 of the Master Theorem applies.


Applying Case 2, we get T (n) ∈ Θ(nlog b a · log n) = Θ(n1/2 log n), which matches our conjecture from
part (a).

COMP 2080: Analysis of Algorithms (Winter 2025) Page 9 of 13


4. For each of the following recurrence relations, state which case of the Master Theorem can be applied and
justify your answer, then use the Master Theorem to find a function g(n) such that T (n) ∈ Θ(g(n)).

(2 marks) (a) 
1, n≤2
T (n) = n

6T 3 + n2 log(n), n>2

Solution: We have a = 6 and b = 3, so log b (a) = log3 (6) ≈ 1.6. The local cost function is
f (n) = n2 log(n), which satisfies f (n) ∈ Ω(nlog6 (3)+ϵ ) for some ϵ > 0 (for example, ϵ = 0.1). Further,
for any n ≥ 1,
n  n 2 n 2 2 n 2 2
af =6 log = n log ≤ n2 log(n) = f (n).
b 3 3 3 3 3 3
Therefore the conditions of Case 3 of the Master Theorem are satisfied. The conclusion of Case 3 is
that T (n) ∈ Θ(n2 log(n)).

(2 marks) (b)
n=1

1,
T (n) = n

8T 2 + 3n3 + n2 , n>1

Solution: We have a = 8 and b = 2, so log b (a) = log2 (8) = 3. The local cost function is f (n) =
3n3 + n2 , which satisfies f (n) ∈ Θ(nlog2 (8) ). Therefore the conditions of Case 2 of the Master Theorem
are satisfied. The conclusion of Case 2 is that T (n) ∈ Θ(n3 log(n)).

(2 marks) (c) 
1, n≤3
T (n) = n

7T 4 + n + log(n), n>3

Solution: We have a = 7 and b = 4, so log b (a) = log4 (7) ≈ 1.4. The local cost function is
f (n) = n + log(n), which satisfies f (n) ∈ O(nlog4 (7)−ϵ ) for some ϵ > 0 (for example, ϵ = 0.1).
Therefore the conditions of Case 1 of the Master Theorem are satisfied. The conclusion of Case 1 is
that T (n) ∈ Θ(nlog4 (7) ).

COMP 2080: Analysis of Algorithms (Winter 2025) Page 10 of 13


(6 marks) 5. Give a complete proof that none of the 3 cases of the Master Theorem apply to the following recurrence
relation. 
1, n≤1
T (n) = n
 n
3T 3 + log n , n > 1

Solution: We have a = 3,b = 3, so log b a = log3 3 = 1, which means that nlog b a = n. The local cost
function is f (n) = n/ log n.
First, we prove that Case 1 cannot be applied, by showing that f (n) ̸∈ O(n1−ϵ ) for all ϵ > 0.

(1) Let ϵ > 0 be an arbitrary real number.

(2) By Fact (1.2), we know that log n ∈ o(nϵ ).

(3) By the definition of little-oh, this means ∀M > 0, ∃n0 > 0, ∀n > n0 , log n ≤ M · nϵ . Re-arranging
the inequality, we conclude ∀M > 0, ∃n0 > 0, ∀n > n0 , n1ϵ ≤ M · log1 n .
€ Š
1 1
(4) By the definition of little-oh and the outcome of previous step, we conclude that nϵ ∈o log n .

(5) By Fact (5.1), n ∈ Θ(n), and applying Fact (3.1) gives us that n ∈ O(n).
€ Š
1 1
(6) Applying Fact (5.4) to the outcome of the previous two steps, we get that n · nϵ ∈ o n· log n , which
€ Š
simplifies to n1−ϵ ∈ o logn n .

n

(7) Applying Fact (3.3) to the outcome of the previous step, we get log n ∈ ω n1−ϵ . Applying Fact
(3.7) gives logn n ̸∈ O n1−ϵ , as desired.


Next, we prove that Case 2 cannot be applied, by showing that f (n) ̸∈ Θ(n).

(1) By Fact (1.1), we know that 1 ∈ o(log n).

(2) By the definition of little-oh, this means ∀M > 0, ∃n0 > 0, ∀n > n0 , 1 ≤ M · log n. Re-arranging the
inequality, we conclude ∀M > 0, ∃n0 > 0, ∀n > n0 , log1 n ≤ M .
1
(3) By the definition of little-oh and the outcome of previous step, we conclude that log n ∈ o (1).

(4) By Fact (5.1), n ∈ Θ(n), and applying Fact (3.1) gives us that n ∈ O(n).
1
(5) Applying Fact (5.4) to the outcome of the previous two steps, we get n · log n ∈ o (n · 1), which
simplifies to logn n ∈ o (n).
n
(6) Applying Fact (3.6) to the outcome of the previous step, we get log n ̸∈ Ω (n). Applying Fact (3.1)
gives logn n ̸∈ Θ (n), as desired.

Finally, we prove that Case 3 cannot be applied, by showing that f (n) ̸∈ Ω(n1+ϵ ) for all ϵ > 0.

(1) Let ϵ > 0 be an arbitrary real number.

(2) By Fact (1.1) we know 1 ∈ o(log n), and by Fact (1.2) we know log n ∈ o(nϵ ). By Fact (2.3), this
implies that 1 ∈ o(nϵ ). Fact (3.4) implies that 1 ∈ O(nϵ ).
n
(3) We proved in step ((5)) above that log n ∈ o (n).

(4) Applying Fact (5.4) to the outcome of the previous two steps, we get n
log n · 1 ∈ o (n · nϵ ), which
simplifies to logn n ∈ o n1+ϵ .


n

(5) Applying Fact (3.6) to the outcome of the previous step, we conclude that log n ̸∈ Ω n1+ϵ , as
desired.

COMP 2080: Analysis of Algorithms (Winter 2025) Page 11 of 13


Definitions and Facts
Definitions
• The symbol Z represents the set of integers {. . . , −2, −1, 0, 1, 2, . . .}.
• The symbol N represents the set of positive integers {1, 2, 3, . . .}.
• The symbol R represents the set of real numbers.
• An integer n is even if there exists an integer k such that n = 2k.
• An integer n is odd if there exists an integer k such that n = 2k + 1.
• The floor of x, denoted by ⌊x⌋, is the largest integer that is less than or equal to x.
• The ceiling of x, denoted by ⌈x⌉, is the smallest integer that is greater than or equal to x.
• For every positive integer x, the double factorial x!! is defined as the product 1 · 3 · 5 · · · (x − 4) · (x − 2) · x when x is odd, and, defined
as the product 2 · 4 · 6 · · · (x − 4) · (x − 2) · x when x is even.

Floors/Ceilings
For any real number x and any real number y ̸= 0:
• −⌊x⌋ = ⌈−x⌉ and −⌈x⌉ = ⌊−x⌋
• for any integer k: ⌊k⌋ = ⌈k⌉ = k
• for any integer k: k + ⌊x/ y⌋ = ⌊k + x/ y⌋
• for any integer k: k + ⌈x/ y⌉ = ⌈k + x/ y⌉
• for any integer k: ⌊(k + 1)/2⌋ = ⌈k/2⌉ and ⌈(k − 1)/2⌉ = ⌊k/2⌋
⌊x/a⌋ x ⌈x/a⌉ x
• for any integers a, b: ⌊ b ⌋ = ⌊ ab ⌋ and ⌈ b ⌉ = ⌈ ab ⌉

Exponentials and Logarithms


For all a, b, c > 0 and all x, y ∈ R:
p
a0 = 1 a1 = a for integer k > 1: a1/k = k a
ax
a x a y = a x+ y a−1 = 1/a = a x− y
x y y x
ay
(a ) = (a ) = a xy
(a b) x = a x b x a < b if and only if a c < b c

For all a, b > 1, and all x, y > 0:

loga (1) = 0 loga €a =Š1 aloga (x) = x and loga (a x ) = x


x log b x
loga (x y) = loga (x) + loga ( y) loga y = loga (x) − loga ( y) loga x = log b a
1
loga (x y ) = y loga (x) loga (1/x) = − loga x log b a = loga b
x < y if and only if loga (x) < loga ( y)

Summation Identities

b n
X X n(n + 1)
1= b−a+1 j=
j=a j=1
2
n n
X
2 n(n + 1)(2n + 1) X n2 (n + 1)2
j = j3 =
j=1
6 j=1
4
n ∞
X q n+1 − 1 X 1
∀q > 0, q ̸= 1, qj = ∀q, 0 < q < 1, qj =
j=0 
q−1 j=0
1−q
  
Xb Xb Xb b
X b
X
( f ( j) + g( j)) =  f ( j) +  g( j) c · f ( j) = c · f ( j) for any constant c
j=a j=a j=a j=a j=a

COMP 2080: Analysis of Algorithms (Winter 2025) Page 12 of 13


Asymptotics
In these statements, a, b and c are constants (i.e., they are not functions of n), and f , g, h, f1 , f2 , g1 and g2 are
functions that map Z+ → R+ .

Group 1: the hierarchy summarized. For all constants a > 0 and b > 0 and c > 0:
(1.1) if a > 1, then c ∈ o(loga (n))
(1.2) if a > 1, then loga (n) ∈ o(n b )
(1.3) if a < b, then na ∈ o(n b )
(1.4) if b > 1, then na ∈ o(b n )
(1.5) if 1 < a < b, then a n ∈ o(b n )
(1.6) a n ∈ o(n!)

Group 2: transitivity.
(2.1) if f ∈ O(g) and g ∈ O(h), then f ∈ O(h)
(2.2) if f ∈ Ω(g) and g ∈ Ω(h), then f ∈ Ω(h)
(2.3) if f ∈ o(g) and g ∈ o(h), then f ∈ o(h)
(2.4) if f ∈ ω(g) and g ∈ ω(h), then f ∈ ω(h)

Group 3: conditionals and biconditionals.


(3.1) f ∈ Θ(g) if and only if f ∈ O(g) and f ∈ Ω(g)
(3.2) f ∈ O(g) if and only if g ∈ Ω( f )
(3.3) f ∈ o(g) if and only if g ∈ ω( f )
(3.4) if f ∈ o(g), then f ∈ O(g)
(3.5) if f ∈ ω(g), then f ∈ Ω(g)
/ Ω(g)
(3.6) If f ∈ o(g), then f ∈
(3.7) If f ∈ ω(g), then f ∈
/ O(g)

Group 4: addition.
(4.1) if f ∈ O(h) and g ∈ O(h), then f + g ∈ O(h)
(4.2) if f ∈ Ω(h), then f + g ∈ Ω(h)
(4.3) if f ∈ o(h) and g ∈ o(h), then f + g ∈ o(h)
(4.4) if f ∈ ω(h), then f + g ∈ ω(h)

Group 5: multiplication.
(5.1) for any constant c > 0, c f ∈ Θ( f )
(5.2) if f1 ∈ O(g1 ) and f2 ∈ O(g2 ) then f1 f2 ∈ O(g1 g2 )
(5.3) if f1 ∈ Ω(g1 ) and f2 ∈ Ω(g2 ) then f1 f2 ∈ Ω(g1 g2 )
(5.4) if f1 ∈ O(g1 ) and f2 ∈ o(g2 ) then f1 f2 ∈ o(g1 g2 )
(5.5) if f1 ∈ Ω(g1 ) and f2 ∈ ω(g2 ) then f1 f2 ∈ ω(g1 g2 )

COMP 2080: Analysis of Algorithms (Winter 2025) Page 13 of 13

You might also like