Algorithmic Analysis Notation
- 29Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What is the primary purpose of asymptotic notation in algorithm analysis?
What is the primary purpose of asymptotic notation in algorithm analysis?
29 questions
- 1
What is the primary purpose of asymptotic notation in algorithm analysis?
- A
To specify the exact base cases for recursive algorithms.
- B
To exactly calculate the running time for all possible input sizes.
- C
To provide precise constant factors for algorithm running times.
- D
To ignore constant factors and focus on the leading term of a function.
Correct answer
DTo ignore constant factors and focus on the leading term of a function.
Explanation
Asymptotic notation, like Big O, is used to abstract away constant factors and lower-order terms, focusing on the growth rate (lead term) of functions for sufficiently large input sizes. This helps in understanding how an algorithm scales.
- A
- 2
Which asymptotic notation is used to represent an upper bound for a function's growth rate?
- A
Big Theta notation, indicating a tight bound on growth.
- B
Big Omega notation, indicating a lower bound on growth.
- C
Little o notation, indicating a strictly smaller growth rate.
- D
Big O notation, indicating an upper bound on growth.
Correct answer
DBig O notation, indicating an upper bound on growth.
Explanation
Big O notation (O(g(n))) provides an upper bound, meaning that f(n) grows no faster than g(n) (up to a constant factor) for sufficiently large n.
- A
- 3
Given f(n)=O(g(n)), what condition must hold for suitable constants c and n0?
- A
0≤f(n)≤cimesg(n) for all n≥n0.
- B
f(n)≤g(n) for all n≥n0 without any constant.
- C
f(n)=g(n) for all n≥n0.
- D
f(n)≥cimesg(n) for all n≥n0.
Correct answer
A0≤f(n)≤cimesg(n) for all n≥n0.
Explanation
The formal definition of f(n)=O(g(n)) states that there exist positive constants c and n0 such that 0≤f(n)≤cimesg(n) for all n≥n0. The non-negative assumption for f(n) is important.
- A
- 4
Why is the equality sign in f(n)=O(g(n)) considered asymmetric?
- A
Because the notation only applies to non-negative functions f(n).
- B
Because O(g(n)) represents a set of functions, not a single value.
- C
Because constant factors are ignored, making true equality impossible.
- D
Because f(n) must always be smaller than g(n) for it to be true.
Correct answer
BBecause O(g(n)) represents a set of functions, not a single value.
Explanation
The notation f(n)=O(g(n)) means that f(n) is a member of the set of functions O(g(n)). Therefore, if A=O(B), it does not imply O(B)=A, making the 'equality' asymmetric.
- A
- 5
In the expression f(n)=n3+O(n2), what does O(n2) represent?
- A
It means that f(n) is strictly less than n3 for large n.
- B
It signifies an exact term that must be precisely n2.
- C
It represents a constant value multiplied by n2 for all n.
- D
It acts as a placeholder for some function h(n) in O(n2).
Correct answer
DIt acts as a placeholder for some function h(n) in O(n2).
Explanation
When O(n2) appears on the right side of an equation, it is a macro representing some function h(n) such that h(n)=O(n2). This is often used to denote an error bound or lower-order terms.
- A
- 6
What is the interpretation of O(n) appearing on the left-hand side of an equation, e.g., O(n2)=O(n3)?
- A
It implies there exists an f(n) in O(n2) that is also in O(n3).
- B
It indicates that n3 is a tighter bound than n2 for the function.
- C
It means that for any function in O(n2), it is also in O(n3).
- D
It means that n2 must be strictly equal to n3 for some n.
Correct answer
CIt means that for any function in O(n2), it is also in O(n3).
Explanation
When O(extsomething) is on the left, it implies that for any expansion of the macro on the left, there is an expansion on the right that makes the equality true. So, any function in O(n2) is also a function in O(n3).
- A
- 7
Which asymptotic notation is used to establish a lower bound for a function's growth rate?
- A
Little o notation, showing a strictly slower growth rate.
- B
Big Omega notation, indicating a lower bound on growth.
- C
Big O notation, indicating an upper limit for growth.
- D
Big Theta notation, indicating a precise asymptotic equivalence.
Correct answer
BBig Omega notation, indicating a lower bound on growth.
Explanation
Big Omega notation (Ω(g(n))) states that f(n) grows at least as fast as g(n) (up to a constant factor) for sufficiently large n, thus providing a lower bound.
- A
- 8
What is the formal definition of f(n)=Ω(g(n))?
- A
There exist c>0 and n0 such that 0≤f(n)≤cimesg(n) for all n≥n0.
- B
There exist c>0 and n0 such that f(n)≥cimesg(n)≥0 for all n≥n0.
- C
There exist c>0 and n0 such that f(n)=g(n) for all n≥n0.
- D
There exist c>0 and n0 such that f(n)<cimesg(n) for all n≥n0.
Correct answer
BThere exist c>0 and n0 such that f(n)≥cimesg(n)≥0 for all n≥n0.
Explanation
The definition of f(n)=Ω(g(n)) requires that there exist positive constants c and n0 such that f(n)≥c×g(n)≥0 for all n≥n0, establishing a lower bound.
- A
- 9
Which asymptotic notation signifies a tight bound, meaning the function grows at the same rate both above and below?
- A
Little o notation, for strictly less than growth.
- B
Big O notation, for an upper bound on growth.
- C
Big Omega notation, for a lower bound on growth.
- D
Big Theta notation, for a tight bound on growth.
Correct answer
DBig Theta notation, for a tight bound on growth.
Explanation
Big Theta notation (Θ(g(n))) signifies a tight bound. It means that f(n) is both O(g(n)) and Ω(g(n)), implying that f(n) and g(n) grow at essentially the same rate.
- A
- 10
How do 'little o' and 'little omega' notations differ from 'Big O' and 'Big Omega'?
- A
Little o and little omega ignore constants, while Big O and Big Omega include them.
- B
They are only used for polynomial functions, unlike their 'Big' counterparts.
- C
They represent strict inequalities for growth rates, not just less/greater than or equal to.
- D
Little o and little omega include lower-order terms, while Big O and Big Omega do not.
Correct answer
CThey represent strict inequalities for growth rates, not just less/greater than or equal to.
Explanation
Little o (o(g(n))) and little omega (ω(g(n))) denote strict asymptotic inequalities, corresponding to 'less than' and 'greater than' respectively, whereas Big O and Big Omega correspond to 'less than or equal to' and 'greater than or equal to'. The definition involves 'for every constant c' rather than 'there exists a constant c'.
- A
- 11
Why is it incorrect to prove n=O(1) by induction using Big O notation directly?
- A
The induction step for n=(n−1)+1 does not apply to Big O relationships.
- B
Big O notation is only for functions with polynomial growth.
- C
The base case 1=O(1) is fundamentally false.
- D
The constant implicit in O(1) would need to change with n.
Correct answer
DThe constant implicit in O(1) would need to change with n.
Explanation
You cannot induct over Big O directly because the implicit constants in the Big O notation can change with each step of the induction. This would mean the constant is dependent on n, invalidating the definition of Big O which requires a fixed constant c.
- A
- 12
What is the primary characteristic of the substitution method for solving recurrences?
- A
It always provides a general closed-form solution without prior knowledge.
- B
It involves guessing a solution and then verifying it using mathematical induction.
- C
It visually represents the recursion as a tree and sums the costs at each level.
- D
It directly applies a predefined theorem to common recurrence patterns.
Correct answer
BIt involves guessing a solution and then verifying it using mathematical induction.
Explanation
The substitution method for solving recurrences is characterized by 'guessing the answer' (or its form) and then using mathematical induction to prove that the guess is correct, often determining the necessary constants in the process.
- A
- 13
In the substitution method, why is it crucial to explicitly use constants rather than Big O notation in the inductive proof?
- A
Using Big O notation can lead to changing implicit constants, invalidating the induction.
- B
The substitution method is exclusively for finding exact constants, not asymptotic bounds.
- C
Big O notation is not mathematically rigorous enough for inductive proofs.
- D
Big O notation makes the proof too complicated and difficult to follow.
Correct answer
AUsing Big O notation can lead to changing implicit constants, invalidating the induction.
Explanation
It is crucial to expand Big O notation into explicit constants (cimesg(n)) when using the substitution method for induction. Using Big O directly can allow the implicit constant to change in each inductive step, leading to an incorrect proof where the constant might depend on n.
- A
- 14
When proving an upper bound T(n)=O(n2) for T(n)=4T(n/2)+n using substitution, why does a direct guess of T(n)≤cn2 fail?
- A
The constant c in the inductive hypothesis is forced to be zero.
- B
The base case T(1)≤c(1)2 requires c to be too small.
- C
The inductive step leads to cn2+n, which is not ≤cn2 for large n.
- D
The recurrence inherently has a lower bound of n3, making n2 impossible.
Correct answer
CThe inductive step leads to cn2+n, which is not ≤cn2 for large n.
Explanation
A direct guess of T(n)≤cn2 for T(n)=4T(n/2)+n fails because after substitution, you get cn2+n. To complete the induction, you need cn2+n≤cn2, which implies n≤0, a contradiction for n≥1. This means the residual term (+n) prevents the simple bound from holding.
- A
- 15
To successfully prove T(n)=O(n2) for T(n)=4T(n/2)+n using substitution, what technique is often employed?
- A
Assuming c can vary with n in the inductive proof.
- B
Ignoring the lower-order term 'n' in the recurrence equation.
- C
Using a different base case, like T(2) instead of T(1).
- D
Guessing a stronger inductive hypothesis, such as T(n)≤c1n2−c2n.
Correct answer
DGuessing a stronger inductive hypothesis, such as T(n)≤c1n2−c2n.
Explanation
When a simple guess like T(n)≤cn2 fails because of lower-order terms, one often 'strengthens' the induction hypothesis by guessing a more precise form, such as T(n)≤c1n2−c2n. This allows the lower-order term to be absorbed or canceled correctly during the inductive step.
- A
- 16
What is the core idea behind the recursion-tree method for solving recurrences?
- A
To visually represent the recursive calls as a tree and sum the costs level by level.
- B
To identify specific patterns that fit into the Master Theorem's cases.
- C
To guess the solution and verify it using mathematical induction.
- D
To convert the recurrence into a closed-form formula using algebraic manipulation.
Correct answer
ATo visually represent the recursive calls as a tree and sum the costs level by level.
Explanation
The recursion-tree method involves drawing out the recursive calls as a tree. The total cost is then found by summing the non-recursive work at each level of the tree and then summing all these level costs.
- A
- 17
In a recursion tree for T(n)=T(n/4)+T(n/2)+n2, what does the value n2 represent at the root?
- A
The total work done by the entire algorithm.
- B
The work done by the recursive calls at that level.
- C
The non-recursive work performed at the top level of the problem.
- D
The size of the subproblems being solved recursively.
Correct answer
CThe non-recursive work performed at the top level of the problem.
Explanation
In a recursion tree, the term n2 (or f(n) in general) represents the non-recursive work done at that particular level of the recursion. The recursive calls T(n/4) and T(n/2) are expanded in subsequent levels.
- A
- 18
For the recurrence T(n)=T(n/4)+T(n/2)+n2, how is the total cost typically computed using the recursion-tree method?
- A
By summing all the leaf nodes in the recursion tree.
- B
By identifying the deepest branch and multiplying its cost by the tree height.
- C
By finding the average cost of all nodes in the tree.
- D
By summing the cost at each level of the tree and then summing these level sums.
Correct answer
DBy summing the cost at each level of the tree and then summing these level sums.
Explanation
The standard procedure for the recursion-tree method is to calculate the total cost at each level of the tree (e.g., n2, then (n/4)2+(n/2)2, etc.) and then sum these level totals to get the overall solution for T(n).
- A
- 19
What is a potential drawback of the recursion-tree method despite its intuitive nature?
- A
It is always more complex to apply than the substitution method.
- B
It is slightly non-rigorous due to the 'dot, dot, dot' summarization of levels.
- C
It requires precise knowledge of the base case, which is often unknown.
- D
It can only be used for recurrences with exactly two recursive calls.
Correct answer
BIt is slightly non-rigorous due to the 'dot, dot, dot' summarization of levels.
Explanation
The recursion-tree method is intuitive but can be non-rigorous because it often relies on generalizing patterns using 'dot, dot, dot' (e.g., for geometric series), which may not always hold or be obvious without formal proof.
- A
- 20
To what specific form of recurrences does the Master Method apply?
- A
T(n)=aT(n−b)+f(n) for linear decrements.
- B
T(n)=T(n/b)+T(n/c)+f(n) for varying subproblem sizes.
- C
T(n)=aT(n/b)+cT(n/d) for multiple recursive terms.
- D
T(n)=aT(n/b)+f(n) where a,b are constants and f(n) is non-recursive work.
Correct answer
DT(n)=aT(n/b)+f(n) where a,b are constants and f(n) is non-recursive work.
Explanation
The Master Method is restrictive and applies only to recurrences of the form T(n)=aT(n/b)+f(n), where a≥1, b>1, and f(n) is an asymptotically positive function representing non-recursive work.
- A
- 21
What function is f(n) compared against in the Master Method to determine the correct case?
- A
nlogba
- B
nlogab
- C
(n/b)+a
- D
f(n/b)
Correct answer
Anlogba
Explanation
The Master Method compares the non-recursive work f(n) to the function nlogba. This particular function represents the cost of the leaves in the recursion tree.
- A
- 22
In Case 1 of the Master Method, what condition must f(n) satisfy relative to nlogba?
- A
f(n)=Ω(nlogba+ϵ) for some ϵ>0.
- B
f(n)=Θ(nlogbalogkn) for k≥0.
- C
f(n)=o(nlogba) but not necessarily polynomially smaller.
- D
f(n)=O(nlogba−ϵ) for some ϵ>0 (polynomially smaller).
Correct answer
Df(n)=O(nlogba−ϵ) for some ϵ>0 (polynomially smaller).
Explanation
Case 1 requires f(n) to be polynomially smaller than nlogba. Specifically, f(n)=O(nlogba−ϵ) for some constant ϵ>0. The 'o' notation here means strictly smaller, but the additional ϵ indicates a polynomial difference.
- A
- 23
If T(n)=4T(n/2)+n, which case of the Master Method applies, and what is the solution?
- A
Case 1; T(n)=Θ(n2).
- B
The Master Method does not apply to this recurrence.
- C
Case 3; T(n)=Θ(n).
- D
Case 2; T(n)=Θ(n2logn).
Correct answer
ACase 1; T(n)=Θ(n2).
Explanation
For T(n)=4T(n/2)+n, we have a=4, b=2, f(n)=n. Calculate nlogba=nlog24=n2. Since f(n)=n is polynomially smaller than n2 (specifically, n=O(n2−1)), Case 1 applies. The solution is T(n)=Θ(nlogba)=Θ(n2).
- A
- 24
In Case 2 of the Master Method, what condition does f(n) satisfy relative to nlogba?
- A
f(n)=Θ(nlogba) exactly.
- B
f(n)=Θ(nlogbalogkn) for some k≥0 (poly-log factor).
- C
f(n) is polynomially smaller than nlogba.
- D
f(n)=Ω(nlogba+ϵ) for some ϵ>0.
Correct answer
Bf(n)=Θ(nlogbalogkn) for some k≥0 (poly-log factor).
Explanation
Case 2 applies when f(n) is asymptotically equal to nlogba, possibly multiplied by a poly-logarithmic factor. Formally, f(n)=Θ(nlogbalogkn) for some constant k≥0.
- A
- 25
If T(n)=4T(n/2)+n2, which case of the Master Method applies, and what is the solution?
- A
The Master Method does not apply to this recurrence.
- B
Case 3; T(n)=Θ(n2).
- C
Case 1; T(n)=Θ(n2).
- D
Case 2; T(n)=Θ(n2logn).
Correct answer
DCase 2; T(n)=Θ(n2logn).
Explanation
For T(n)=4T(n/2)+n2, we have a=4, b=2, f(n)=n2. Calculate nlogba=nlog24=n2. Since f(n)=n2 is asymptotically equal to n2 (with k=0 in the logkn term), Case 2 applies. The solution is T(n)=Θ(nlogbalog0+1n)=Θ(n2logn).
- A
- 26
In Case 3 of the Master Method, what condition must f(n) satisfy relative to nlogba?
- A
f(n) grows at the same rate as nlogba.
- B
f(n)=Θ(nlogbalogkn) for some k≥0.
- C
f(n)=Ω(nlogba+ϵ) for some ϵ>0 (polynomially larger), plus a regularity condition.
- D
f(n)=O(nlogba−ϵ) for some ϵ>0.
Correct answer
Cf(n)=Ω(nlogba+ϵ) for some ϵ>0 (polynomially larger), plus a regularity condition.
Explanation
Case 3 requires f(n) to be polynomially larger than nlogba. Specifically, f(n)=Ω(nlogba+ϵ) for some constant ϵ>0. Additionally, a 'regularity condition' (af(n/b)≤(1−ϵ′)f(n) for some ϵ′>0) must hold to ensure f(n) dominates.
- A
- 27
If T(n)=4T(n/2)+n3, which case of the Master Method applies, and what is the solution?
- A
The Master Method does not apply to this recurrence.
- B
Case 1; T(n)=Θ(n2).
- C
Case 3; T(n)=Θ(n3).
- D
Case 2; T(n)=Θ(n2logn).
Correct answer
CCase 3; T(n)=Θ(n3).
Explanation
For T(n)=4T(n/2)+n3, we have a=4, b=2, f(n)=n3. Calculate nlogba=nlog24=n2. Since f(n)=n3 is polynomially larger than n2 (n3=Ω(n2+1)), Case 3 applies. The solution is T(n)=Θ(f(n))=Θ(n3). (The regularity condition 4(n/2)3≤(1−ϵ′)n3⟹4n3/8≤(1−ϵ′)n3⟹0.5n3≤(1−ϵ′)n3 holds for ϵ′=0.5).
- A
- 28
What is the physical interpretation of nlogba in the context of the Master Method and recursion trees?
- A
It represents the total height of the recursion tree.
- B
It represents the number of subproblems created at each level.
- C
It represents the number of leaves in the recursion tree (up to a constant factor).
- D
It represents the total cost contributed by the non-recursive work f(n).
Correct answer
CIt represents the number of leaves in the recursion tree (up to a constant factor).
Explanation
The term nlogba in the Master Method corresponds to the number of leaves in the recursion tree. This is derived from the height of the tree (h=logbn) and the branching factor (a), leading to ah=alogbn=nlogba leaves.
- A
- 29
Which recurrence would typically NOT be solvable directly by the Master Method?
- A
T(n)=T(n/2)+T(n/3)+n
- B
T(n)=3T(n/3)+n
- C
T(n)=2T(n/4)+n
- D
T(n)=2T(n/2)+nlogn
Correct answer
AT(n)=T(n/2)+T(n/3)+n
Explanation
The Master Method requires all recursive subproblems to be of the same size, i.e., aT(n/b). The recurrence T(n)=T(n/2)+T(n/3)+n involves subproblems of different sizes (n/2 and n/3), so the Master Method cannot be directly applied. It is more suited for recursion-tree method.
- A

Ask anything
We've read this whole study set, so questions about it get the best answers.