1. Home
  2. Explore
  3. Computer Science
  4. Algorithmic Analysis Notation

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Algorithmic Analysis Notation

  • 29Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Asymptotic Notation

What is the primary purpose of asymptotic notation in algorithm analysis?

29 questions

  1. 1

    What is the primary purpose of asymptotic notation in algorithm analysis?

    1. A

      To specify the exact base cases for recursive algorithms.

    2. B

      To exactly calculate the running time for all possible input sizes.

    3. C

      To provide precise constant factors for algorithm running times.

    4. D

      To ignore constant factors and focus on the leading term of a function.

    Correct answer
    D

    To 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.

  2. 2

    Which asymptotic notation is used to represent an upper bound for a function's growth rate?

    1. A

      Big Theta notation, indicating a tight bound on growth.

    2. B

      Big Omega notation, indicating a lower bound on growth.

    3. C

      Little o notation, indicating a strictly smaller growth rate.

    4. D

      Big O notation, indicating an upper bound on growth.

    Correct answer
    D

    Big O notation, indicating an upper bound on growth.

    Explanation

    Big O notation (O(g(n))O(g(n))O(g(n))) provides an upper bound, meaning that f(n)f(n)f(n) grows no faster than g(n)g(n)g(n) (up to a constant factor) for sufficiently large nnn.

  3. 3

    Given f(n)=O(g(n))f(n) = O(g(n))f(n)=O(g(n)), what condition must hold for suitable constants ccc and n0n_0n0​?

    1. A

      0≤f(n)≤cimesg(n)0 \le f(n) \le c imes g(n)0≤f(n)≤cimesg(n) for all n≥n0n \ge n_0n≥n0​.

    2. B

      f(n)≤g(n)f(n) \le g(n)f(n)≤g(n) for all n≥n0n \ge n_0n≥n0​ without any constant.

    3. C

      f(n)=g(n)f(n) = g(n)f(n)=g(n) for all n≥n0n \ge n_0n≥n0​.

    4. D

      f(n)≥cimesg(n)f(n) \ge c imes g(n)f(n)≥cimesg(n) for all n≥n0n \ge n_0n≥n0​.

    Correct answer
    A

    0≤f(n)≤cimesg(n)0 \le f(n) \le c imes g(n)0≤f(n)≤cimesg(n) for all n≥n0n \ge n_0n≥n0​.

    Explanation

    The formal definition of f(n)=O(g(n))f(n) = O(g(n))f(n)=O(g(n)) states that there exist positive constants ccc and n0n_0n0​ such that 0≤f(n)≤cimesg(n)0 \le f(n) \le c imes g(n)0≤f(n)≤cimesg(n) for all n≥n0n \ge n_0n≥n0​. The non-negative assumption for f(n)f(n)f(n) is important.

  4. 4

    Why is the equality sign in f(n)=O(g(n))f(n) = O(g(n))f(n)=O(g(n)) considered asymmetric?

    1. A

      Because the notation only applies to non-negative functions f(n)f(n)f(n).

    2. B

      Because O(g(n))O(g(n))O(g(n)) represents a set of functions, not a single value.

    3. C

      Because constant factors are ignored, making true equality impossible.

    4. D

      Because f(n)f(n)f(n) must always be smaller than g(n)g(n)g(n) for it to be true.

    Correct answer
    B

    Because O(g(n))O(g(n))O(g(n)) represents a set of functions, not a single value.

    Explanation

    The notation f(n)=O(g(n))f(n) = O(g(n))f(n)=O(g(n)) means that f(n)f(n)f(n) is a member of the set of functions O(g(n))O(g(n))O(g(n)). Therefore, if A=O(B)A = O(B)A=O(B), it does not imply O(B)=AO(B) = AO(B)=A, making the 'equality' asymmetric.

  5. 5

    In the expression f(n)=n3+O(n2)f(n) = n^3 + O(n^2)f(n)=n3+O(n2), what does O(n2)O(n^2)O(n2) represent?

    1. A

      It means that f(n)f(n)f(n) is strictly less than n3n^3n3 for large nnn.

    2. B

      It signifies an exact term that must be precisely n2n^2n2.

    3. C

      It represents a constant value multiplied by n2n^2n2 for all nnn.

    4. D

      It acts as a placeholder for some function h(n)h(n)h(n) in O(n2)O(n^2)O(n2).

    Correct answer
    D

    It acts as a placeholder for some function h(n)h(n)h(n) in O(n2)O(n^2)O(n2).

    Explanation

    When O(n2)O(n^2)O(n2) appears on the right side of an equation, it is a macro representing some function h(n)h(n)h(n) such that h(n)=O(n2)h(n) = O(n^2)h(n)=O(n2). This is often used to denote an error bound or lower-order terms.

  6. 6

    What is the interpretation of O(n)O(n)O(n) appearing on the left-hand side of an equation, e.g., O(n2)=O(n3)O(n^2) = O(n^3)O(n2)=O(n3)?

    1. A

      It implies there exists an f(n)f(n)f(n) in O(n2)O(n^2)O(n2) that is also in O(n3)O(n^3)O(n3).

    2. B

      It indicates that n3n^3n3 is a tighter bound than n2n^2n2 for the function.

    3. C

      It means that for any function in O(n2)O(n^2)O(n2), it is also in O(n3)O(n^3)O(n3).

    4. D

      It means that n2n^2n2 must be strictly equal to n3n^3n3 for some nnn.

    Correct answer
    C

    It means that for any function in O(n2)O(n^2)O(n2), it is also in O(n3)O(n^3)O(n3).

    Explanation

    When O(extsomething)O( ext{something})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)O(n^2)O(n2) is also a function in O(n3)O(n^3)O(n3).

  7. 7

    Which asymptotic notation is used to establish a lower bound for a function's growth rate?

    1. A

      Little o notation, showing a strictly slower growth rate.

    2. B

      Big Omega notation, indicating a lower bound on growth.

    3. C

      Big O notation, indicating an upper limit for growth.

    4. D

      Big Theta notation, indicating a precise asymptotic equivalence.

    Correct answer
    B

    Big Omega notation, indicating a lower bound on growth.

    Explanation

    Big Omega notation (Ω(g(n))\Omega(g(n))Ω(g(n))) states that f(n)f(n)f(n) grows at least as fast as g(n)g(n)g(n) (up to a constant factor) for sufficiently large nnn, thus providing a lower bound.

  8. 8

    What is the formal definition of f(n)=Ω(g(n))f(n) = \Omega(g(n))f(n)=Ω(g(n))?

    1. A

      There exist c>0c > 0c>0 and n0n_0n0​ such that 0≤f(n)≤cimesg(n)0 \le f(n) \le c imes g(n)0≤f(n)≤cimesg(n) for all n≥n0n \ge n_0n≥n0​.

    2. B

      There exist c>0c > 0c>0 and n0n_0n0​ such that f(n)≥cimesg(n)≥0f(n) \ge c imes g(n) \ge 0f(n)≥cimesg(n)≥0 for all n≥n0n \ge n_0n≥n0​.

    3. C

      There exist c>0c > 0c>0 and n0n_0n0​ such that f(n)=g(n)f(n) = g(n)f(n)=g(n) for all n≥n0n \ge n_0n≥n0​.

    4. D

      There exist c>0c > 0c>0 and n0n_0n0​ such that f(n)<cimesg(n)f(n) < c imes g(n)f(n)<cimesg(n) for all n≥n0n \ge n_0n≥n0​.

    Correct answer
    B

    There exist c>0c > 0c>0 and n0n_0n0​ such that f(n)≥cimesg(n)≥0f(n) \ge c imes g(n) \ge 0f(n)≥cimesg(n)≥0 for all n≥n0n \ge n_0n≥n0​.

    Explanation

    The definition of f(n)=Ω(g(n))f(n) = \Omega(g(n))f(n)=Ω(g(n)) requires that there exist positive constants ccc and n0n_0n0​ such that f(n)≥c×g(n)≥0f(n) \ge c \times g(n) \ge 0f(n)≥c×g(n)≥0 for all n≥n0n \ge n_0n≥n0​, establishing a lower bound.

  9. 9

    Which asymptotic notation signifies a tight bound, meaning the function grows at the same rate both above and below?

    1. A

      Little o notation, for strictly less than growth.

    2. B

      Big O notation, for an upper bound on growth.

    3. C

      Big Omega notation, for a lower bound on growth.

    4. D

      Big Theta notation, for a tight bound on growth.

    Correct answer
    D

    Big Theta notation, for a tight bound on growth.

    Explanation

    Big Theta notation (Θ(g(n))\Theta(g(n))Θ(g(n))) signifies a tight bound. It means that f(n)f(n)f(n) is both O(g(n))O(g(n))O(g(n)) and Ω(g(n))\Omega(g(n))Ω(g(n)), implying that f(n)f(n)f(n) and g(n)g(n)g(n) grow at essentially the same rate.

  10. 10

    How do 'little o' and 'little omega' notations differ from 'Big O' and 'Big Omega'?

    1. A

      Little o and little omega ignore constants, while Big O and Big Omega include them.

    2. B

      They are only used for polynomial functions, unlike their 'Big' counterparts.

    3. C

      They represent strict inequalities for growth rates, not just less/greater than or equal to.

    4. D

      Little o and little omega include lower-order terms, while Big O and Big Omega do not.

    Correct answer
    C

    They represent strict inequalities for growth rates, not just less/greater than or equal to.

    Explanation

    Little o (o(g(n))o(g(n))o(g(n))) and little omega (ω(g(n))\omega(g(n))ω(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'.

  11. 11

    Why is it incorrect to prove n=O(1)n = O(1)n=O(1) by induction using Big O notation directly?

    1. A

      The induction step for n=(n−1)+1n = (n-1)+1n=(n−1)+1 does not apply to Big O relationships.

    2. B

      Big O notation is only for functions with polynomial growth.

    3. C

      The base case 1=O(1)1 = O(1)1=O(1) is fundamentally false.

    4. D

      The constant implicit in O(1)O(1)O(1) would need to change with nnn.

    Correct answer
    D

    The constant implicit in O(1)O(1)O(1) would need to change with nnn.

    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 nnn, invalidating the definition of Big O which requires a fixed constant ccc.

  12. 12

    What is the primary characteristic of the substitution method for solving recurrences?

    1. A

      It always provides a general closed-form solution without prior knowledge.

    2. B

      It involves guessing a solution and then verifying it using mathematical induction.

    3. C

      It visually represents the recursion as a tree and sums the costs at each level.

    4. D

      It directly applies a predefined theorem to common recurrence patterns.

    Correct answer
    B

    It 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.

  13. 13

    In the substitution method, why is it crucial to explicitly use constants rather than Big O notation in the inductive proof?

    1. A

      Using Big O notation can lead to changing implicit constants, invalidating the induction.

    2. B

      The substitution method is exclusively for finding exact constants, not asymptotic bounds.

    3. C

      Big O notation is not mathematically rigorous enough for inductive proofs.

    4. D

      Big O notation makes the proof too complicated and difficult to follow.

    Correct answer
    A

    Using 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)c imes g(n)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 nnn.

  14. 14

    When proving an upper bound T(n)=O(n2)T(n) = O(n^2)T(n)=O(n2) for T(n)=4T(n/2)+nT(n) = 4T(n/2) + nT(n)=4T(n/2)+n using substitution, why does a direct guess of T(n)≤cn2T(n) \le cn^2T(n)≤cn2 fail?

    1. A

      The constant ccc in the inductive hypothesis is forced to be zero.

    2. B

      The base case T(1)≤c(1)2T(1) \le c(1)^2T(1)≤c(1)2 requires ccc to be too small.

    3. C

      The inductive step leads to cn2+ncn^2 + ncn2+n, which is not ≤cn2\le cn^2≤cn2 for large nnn.

    4. D

      The recurrence inherently has a lower bound of n3n^3n3, making n2n^2n2 impossible.

    Correct answer
    C

    The inductive step leads to cn2+ncn^2 + ncn2+n, which is not ≤cn2\le cn^2≤cn2 for large nnn.

    Explanation

    A direct guess of T(n)≤cn2T(n) \le cn^2T(n)≤cn2 for T(n)=4T(n/2)+nT(n) = 4T(n/2) + nT(n)=4T(n/2)+n fails because after substitution, you get cn2+ncn^2 + ncn2+n. To complete the induction, you need cn2+n≤cn2cn^2 + n \le cn^2cn2+n≤cn2, which implies n≤0n \le 0n≤0, a contradiction for n≥1n \ge 1n≥1. This means the residual term (+n+n+n) prevents the simple bound from holding.

  15. 15

    To successfully prove T(n)=O(n2)T(n) = O(n^2)T(n)=O(n2) for T(n)=4T(n/2)+nT(n) = 4T(n/2) + nT(n)=4T(n/2)+n using substitution, what technique is often employed?

    1. A

      Assuming ccc can vary with nnn in the inductive proof.

    2. B

      Ignoring the lower-order term 'n' in the recurrence equation.

    3. C

      Using a different base case, like T(2)T(2)T(2) instead of T(1)T(1)T(1).

    4. D

      Guessing a stronger inductive hypothesis, such as T(n)≤c1n2−c2nT(n) \le c_1n^2 - c_2nT(n)≤c1​n2−c2​n.

    Correct answer
    D

    Guessing a stronger inductive hypothesis, such as T(n)≤c1n2−c2nT(n) \le c_1n^2 - c_2nT(n)≤c1​n2−c2​n.

    Explanation

    When a simple guess like T(n)≤cn2T(n) \le cn^2T(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−c2nT(n) \le c_1n^2 - c_2nT(n)≤c1​n2−c2​n. This allows the lower-order term to be absorbed or canceled correctly during the inductive step.

  16. 16

    What is the core idea behind the recursion-tree method for solving recurrences?

    1. A

      To visually represent the recursive calls as a tree and sum the costs level by level.

    2. B

      To identify specific patterns that fit into the Master Theorem's cases.

    3. C

      To guess the solution and verify it using mathematical induction.

    4. D

      To convert the recurrence into a closed-form formula using algebraic manipulation.

    Correct answer
    A

    To 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.

  17. 17

    In a recursion tree for T(n)=T(n/4)+T(n/2)+n2T(n) = T(n/4) + T(n/2) + n^2T(n)=T(n/4)+T(n/2)+n2, what does the value n2n^2n2 represent at the root?

    1. A

      The total work done by the entire algorithm.

    2. B

      The work done by the recursive calls at that level.

    3. C

      The non-recursive work performed at the top level of the problem.

    4. D

      The size of the subproblems being solved recursively.

    Correct answer
    C

    The non-recursive work performed at the top level of the problem.

    Explanation

    In a recursion tree, the term n2n^2n2 (or f(n)f(n)f(n) in general) represents the non-recursive work done at that particular level of the recursion. The recursive calls T(n/4)T(n/4)T(n/4) and T(n/2)T(n/2)T(n/2) are expanded in subsequent levels.

  18. 18

    For the recurrence T(n)=T(n/4)+T(n/2)+n2T(n) = T(n/4) + T(n/2) + n^2T(n)=T(n/4)+T(n/2)+n2, how is the total cost typically computed using the recursion-tree method?

    1. A

      By summing all the leaf nodes in the recursion tree.

    2. B

      By identifying the deepest branch and multiplying its cost by the tree height.

    3. C

      By finding the average cost of all nodes in the tree.

    4. D

      By summing the cost at each level of the tree and then summing these level sums.

    Correct answer
    D

    By 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., n2n^2n2, then (n/4)2+(n/2)2 (n/4)^2 + (n/2)^2(n/4)2+(n/2)2, etc.) and then sum these level totals to get the overall solution for T(n)T(n)T(n).

  19. 19

    What is a potential drawback of the recursion-tree method despite its intuitive nature?

    1. A

      It is always more complex to apply than the substitution method.

    2. B

      It is slightly non-rigorous due to the 'dot, dot, dot' summarization of levels.

    3. C

      It requires precise knowledge of the base case, which is often unknown.

    4. D

      It can only be used for recurrences with exactly two recursive calls.

    Correct answer
    B

    It 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.

  20. 20

    To what specific form of recurrences does the Master Method apply?

    1. A

      T(n)=aT(n−b)+f(n)T(n) = aT(n-b) + f(n)T(n)=aT(n−b)+f(n) for linear decrements.

    2. B

      T(n)=T(n/b)+T(n/c)+f(n)T(n) = T(n/b) + T(n/c) + f(n)T(n)=T(n/b)+T(n/c)+f(n) for varying subproblem sizes.

    3. C

      T(n)=aT(n/b)+cT(n/d)T(n) = aT(n/b) + cT(n/d)T(n)=aT(n/b)+cT(n/d) for multiple recursive terms.

    4. D

      T(n)=aT(n/b)+f(n)T(n) = aT(n/b) + f(n)T(n)=aT(n/b)+f(n) where a,ba, ba,b are constants and f(n)f(n)f(n) is non-recursive work.

    Correct answer
    D

    T(n)=aT(n/b)+f(n)T(n) = aT(n/b) + f(n)T(n)=aT(n/b)+f(n) where a,ba, ba,b are constants and f(n)f(n)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)T(n) = aT(n/b) + f(n)T(n)=aT(n/b)+f(n), where a≥1a \ge 1a≥1, b>1b > 1b>1, and f(n)f(n)f(n) is an asymptotically positive function representing non-recursive work.

  21. 21

    What function is f(n)f(n)f(n) compared against in the Master Method to determine the correct case?

    1. A

      nlog⁡ban^{\log_b a}nlogb​a

    2. B

      nlog⁡abn^{\log_a b}nloga​b

    3. C

      (n/b)+a(n/b) + a(n/b)+a

    4. D

      f(n/b)f(n/b)f(n/b)

    Correct answer
    A

    nlog⁡ban^{\log_b a}nlogb​a

    Explanation

    The Master Method compares the non-recursive work f(n)f(n)f(n) to the function nlog⁡ban^{\log_b a}nlogb​a. This particular function represents the cost of the leaves in the recursion tree.

  22. 22

    In Case 1 of the Master Method, what condition must f(n)f(n)f(n) satisfy relative to nlog⁡ban^{\log_b a}nlogb​a?

    1. A

      f(n)=Ω(nlog⁡ba+ϵ)f(n) = \Omega(n^{\log_b a + \epsilon})f(n)=Ω(nlogb​a+ϵ) for some ϵ>0\epsilon > 0ϵ>0.

    2. B

      f(n)=Θ(nlog⁡balog⁡kn)f(n) = \Theta(n^{\log_b a} \log^k n)f(n)=Θ(nlogb​alogkn) for k≥0k \ge 0k≥0.

    3. C

      f(n)=o(nlog⁡ba)f(n) = o(n^{\log_b a})f(n)=o(nlogb​a) but not necessarily polynomially smaller.

    4. D

      f(n)=O(nlog⁡ba−ϵ)f(n) = O(n^{\log_b a - \epsilon})f(n)=O(nlogb​a−ϵ) for some ϵ>0\epsilon > 0ϵ>0 (polynomially smaller).

    Correct answer
    D

    f(n)=O(nlog⁡ba−ϵ)f(n) = O(n^{\log_b a - \epsilon})f(n)=O(nlogb​a−ϵ) for some ϵ>0\epsilon > 0ϵ>0 (polynomially smaller).

    Explanation

    Case 1 requires f(n)f(n)f(n) to be polynomially smaller than nlog⁡ban^{\log_b a}nlogb​a. Specifically, f(n)=O(nlog⁡ba−ϵ)f(n) = O(n^{\log_b a - \epsilon})f(n)=O(nlogb​a−ϵ) for some constant ϵ>0\epsilon > 0ϵ>0. The 'o' notation here means strictly smaller, but the additional ϵ\epsilonϵ indicates a polynomial difference.

  23. 23

    If T(n)=4T(n/2)+nT(n) = 4T(n/2) + nT(n)=4T(n/2)+n, which case of the Master Method applies, and what is the solution?

    1. A

      Case 1; T(n)=Θ(n2)T(n) = \Theta(n^2)T(n)=Θ(n2).

    2. B

      The Master Method does not apply to this recurrence.

    3. C

      Case 3; T(n)=Θ(n)T(n) = \Theta(n)T(n)=Θ(n).

    4. D

      Case 2; T(n)=Θ(n2log⁡n)T(n) = \Theta(n^2 \log n)T(n)=Θ(n2logn).

    Correct answer
    A

    Case 1; T(n)=Θ(n2)T(n) = \Theta(n^2)T(n)=Θ(n2).

    Explanation

    For T(n)=4T(n/2)+nT(n) = 4T(n/2) + nT(n)=4T(n/2)+n, we have a=4a=4a=4, b=2b=2b=2, f(n)=nf(n)=nf(n)=n. Calculate nlog⁡ba=nlog⁡24=n2n^{\log_b a} = n^{\log_2 4} = n^2nlogb​a=nlog2​4=n2. Since f(n)=nf(n)=nf(n)=n is polynomially smaller than n2n^2n2 (specifically, n=O(n2−1)n = O(n^{2-1})n=O(n2−1)), Case 1 applies. The solution is T(n)=Θ(nlog⁡ba)=Θ(n2)T(n) = \Theta(n^{\log_b a}) = \Theta(n^2)T(n)=Θ(nlogb​a)=Θ(n2).

  24. 24

    In Case 2 of the Master Method, what condition does f(n)f(n)f(n) satisfy relative to nlog⁡ban^{\log_b a}nlogb​a?

    1. A

      f(n)=Θ(nlog⁡ba)f(n) = \Theta(n^{\log_b a})f(n)=Θ(nlogb​a) exactly.

    2. B

      f(n)=Θ(nlog⁡balog⁡kn)f(n) = \Theta(n^{\log_b a} \log^k n)f(n)=Θ(nlogb​alogkn) for some k≥0k \ge 0k≥0 (poly-log factor).

    3. C

      f(n)f(n)f(n) is polynomially smaller than nlog⁡ban^{\log_b a}nlogb​a.

    4. D

      f(n)=Ω(nlog⁡ba+ϵ)f(n) = \Omega(n^{\log_b a + \epsilon})f(n)=Ω(nlogb​a+ϵ) for some ϵ>0\epsilon > 0ϵ>0.

    Correct answer
    B

    f(n)=Θ(nlog⁡balog⁡kn)f(n) = \Theta(n^{\log_b a} \log^k n)f(n)=Θ(nlogb​alogkn) for some k≥0k \ge 0k≥0 (poly-log factor).

    Explanation

    Case 2 applies when f(n)f(n)f(n) is asymptotically equal to nlog⁡ban^{\log_b a}nlogb​a, possibly multiplied by a poly-logarithmic factor. Formally, f(n)=Θ(nlog⁡balog⁡kn)f(n) = \Theta(n^{\log_b a} \log^k n)f(n)=Θ(nlogb​alogkn) for some constant k≥0k \ge 0k≥0.

  25. 25

    If T(n)=4T(n/2)+n2T(n) = 4T(n/2) + n^2T(n)=4T(n/2)+n2, which case of the Master Method applies, and what is the solution?

    1. A

      The Master Method does not apply to this recurrence.

    2. B

      Case 3; T(n)=Θ(n2)T(n) = \Theta(n^2)T(n)=Θ(n2).

    3. C

      Case 1; T(n)=Θ(n2)T(n) = \Theta(n^2)T(n)=Θ(n2).

    4. D

      Case 2; T(n)=Θ(n2log⁡n)T(n) = \Theta(n^2 \log n)T(n)=Θ(n2logn).

    Correct answer
    D

    Case 2; T(n)=Θ(n2log⁡n)T(n) = \Theta(n^2 \log n)T(n)=Θ(n2logn).

    Explanation

    For T(n)=4T(n/2)+n2T(n) = 4T(n/2) + n^2T(n)=4T(n/2)+n2, we have a=4a=4a=4, b=2b=2b=2, f(n)=n2f(n)=n^2f(n)=n2. Calculate nlog⁡ba=nlog⁡24=n2n^{\log_b a} = n^{\log_2 4} = n^2nlogb​a=nlog2​4=n2. Since f(n)=n2f(n)=n^2f(n)=n2 is asymptotically equal to n2n^2n2 (with k=0k=0k=0 in the log⁡kn\log^k nlogkn term), Case 2 applies. The solution is T(n)=Θ(nlog⁡balog⁡0+1n)=Θ(n2log⁡n)T(n) = \Theta(n^{\log_b a} \log^{0+1} n) = \Theta(n^2 \log n)T(n)=Θ(nlogb​alog0+1n)=Θ(n2logn).

  26. 26

    In Case 3 of the Master Method, what condition must f(n)f(n)f(n) satisfy relative to nlog⁡ban^{\log_b a}nlogb​a?

    1. A

      f(n)f(n)f(n) grows at the same rate as nlog⁡ban^{\log_b a}nlogb​a.

    2. B

      f(n)=Θ(nlog⁡balog⁡kn)f(n) = \Theta(n^{\log_b a} \log^k n)f(n)=Θ(nlogb​alogkn) for some k≥0k \ge 0k≥0.

    3. C

      f(n)=Ω(nlog⁡ba+ϵ)f(n) = \Omega(n^{\log_b a + \epsilon})f(n)=Ω(nlogb​a+ϵ) for some ϵ>0\epsilon > 0ϵ>0 (polynomially larger), plus a regularity condition.

    4. D

      f(n)=O(nlog⁡ba−ϵ)f(n) = O(n^{\log_b a - \epsilon})f(n)=O(nlogb​a−ϵ) for some ϵ>0\epsilon > 0ϵ>0.

    Correct answer
    C

    f(n)=Ω(nlog⁡ba+ϵ)f(n) = \Omega(n^{\log_b a + \epsilon})f(n)=Ω(nlogb​a+ϵ) for some ϵ>0\epsilon > 0ϵ>0 (polynomially larger), plus a regularity condition.

    Explanation

    Case 3 requires f(n)f(n)f(n) to be polynomially larger than nlog⁡ban^{\log_b a}nlogb​a. Specifically, f(n)=Ω(nlog⁡ba+ϵ)f(n) = \Omega(n^{\log_b a + \epsilon})f(n)=Ω(nlogb​a+ϵ) for some constant ϵ>0\epsilon > 0ϵ>0. Additionally, a 'regularity condition' (af(n/b)≤(1−ϵ′)f(n)af(n/b) \le (1-\epsilon')f(n)af(n/b)≤(1−ϵ′)f(n) for some ϵ′>0\epsilon' > 0ϵ′>0) must hold to ensure f(n)f(n)f(n) dominates.

  27. 27

    If T(n)=4T(n/2)+n3T(n) = 4T(n/2) + n^3T(n)=4T(n/2)+n3, which case of the Master Method applies, and what is the solution?

    1. A

      The Master Method does not apply to this recurrence.

    2. B

      Case 1; T(n)=Θ(n2)T(n) = \Theta(n^2)T(n)=Θ(n2).

    3. C

      Case 3; T(n)=Θ(n3)T(n) = \Theta(n^3)T(n)=Θ(n3).

    4. D

      Case 2; T(n)=Θ(n2log⁡n)T(n) = \Theta(n^2 \log n)T(n)=Θ(n2logn).

    Correct answer
    C

    Case 3; T(n)=Θ(n3)T(n) = \Theta(n^3)T(n)=Θ(n3).

    Explanation

    For T(n)=4T(n/2)+n3T(n) = 4T(n/2) + n^3T(n)=4T(n/2)+n3, we have a=4a=4a=4, b=2b=2b=2, f(n)=n3f(n)=n^3f(n)=n3. Calculate nlog⁡ba=nlog⁡24=n2n^{\log_b a} = n^{\log_2 4} = n^2nlogb​a=nlog2​4=n2. Since f(n)=n3f(n)=n^3f(n)=n3 is polynomially larger than n2n^2n2 (n3=Ω(n2+1)n^3 = \Omega(n^{2+1})n3=Ω(n2+1)), Case 3 applies. The solution is T(n)=Θ(f(n))=Θ(n3)T(n) = \Theta(f(n)) = \Theta(n^3)T(n)=Θ(f(n))=Θ(n3). (The regularity condition 4(n/2)3≤(1−ϵ′)n3  ⟹  4n3/8≤(1−ϵ′)n3  ⟹  0.5n3≤(1−ϵ′)n34(n/2)^3 \le (1-\epsilon')n^3 \implies 4n^3/8 \le (1-\epsilon')n^3 \implies 0.5n^3 \le (1-\epsilon')n^34(n/2)3≤(1−ϵ′)n3⟹4n3/8≤(1−ϵ′)n3⟹0.5n3≤(1−ϵ′)n3 holds for ϵ′=0.5\epsilon' = 0.5ϵ′=0.5).

  28. 28

    What is the physical interpretation of nlog⁡ban^{\log_b a}nlogb​a in the context of the Master Method and recursion trees?

    1. A

      It represents the total height of the recursion tree.

    2. B

      It represents the number of subproblems created at each level.

    3. C

      It represents the number of leaves in the recursion tree (up to a constant factor).

    4. D

      It represents the total cost contributed by the non-recursive work f(n)f(n)f(n).

    Correct answer
    C

    It represents the number of leaves in the recursion tree (up to a constant factor).

    Explanation

    The term nlog⁡ban^{\log_b a}nlogb​a in the Master Method corresponds to the number of leaves in the recursion tree. This is derived from the height of the tree (h=log⁡bnh = \log_b nh=logb​n) and the branching factor (aaa), leading to ah=alog⁡bn=nlog⁡baa^h = a^{\log_b n} = n^{\log_b a}ah=alogb​n=nlogb​a leaves.

  29. 29

    Which recurrence would typically NOT be solvable directly by the Master Method?

    1. A

      T(n)=T(n/2)+T(n/3)+nT(n) = T(n/2) + T(n/3) + nT(n)=T(n/2)+T(n/3)+n

    2. B

      T(n)=3T(n/3)+nT(n) = 3T(n/3) + nT(n)=3T(n/3)+n

    3. C

      T(n)=2T(n/4)+nT(n) = 2T(n/4) + nT(n)=2T(n/4)+n

    4. D

      T(n)=2T(n/2)+nlog⁡nT(n) = 2T(n/2) + n \log nT(n)=2T(n/2)+nlogn

    Correct answer
    A

    T(n)=T(n/2)+T(n/3)+nT(n) = T(n/2) + T(n/3) + nT(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)aT(n/b)aT(n/b). The recurrence T(n)=T(n/2)+T(n/3)+nT(n) = T(n/2) + T(n/3) + nT(n)=T(n/2)+T(n/3)+n involves subproblems of different sizes (n/2n/2n/2 and n/3n/3n/3), so the Master Method cannot be directly applied. It is more suited for recursion-tree method.

Question 1 of 29
Question 1 of 29

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent