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

  • 21Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Asymptotic Notation
  • spaceFlip card
  • KI knew it
  • DI didn't know it
  • ←Previous card
  • →Next card

What does the notation f(n)=O(g(n))f(n) = O(g(n))f(n)=O(g(n)) mean mathematically?

Tap to flipClick to flipspace

It means there exist suitable constants ccc and n0n_0n0​ such that f(n)f(n)f(n) is bounded by c⋅g(n)c \cdot g(n)c⋅g(n) for all n≥n0n \ge n_0n≥n0​. This assumes f(n)f(n)f(n) is non-negative.

Or swipe the card

21 cards

  1. What does the notation f(n)=O(g(n))f(n) = O(g(n))f(n)=O(g(n)) mean mathematically?

    It means there exist suitable constants ccc and n0n_0n0​ such that f(n)f(n)f(n) is bounded by c⋅g(n)c \cdot g(n)c⋅g(n) for all n≥n0n \ge n_0n≥n0​. This assumes f(n)f(n)f(n) is non-negative.

  2. How does the equal sign behave in asymptotic notation like f(n)=O(g(n))f(n) = O(g(n))f(n)=O(g(n))?

    The equal sign is asymmetric. It should be read as 'is' or 'is in the set of'. For example, 2n2=O(n3)2n^2 = O(n^3)2n2=O(n3) means 2n22n^22n2 is in the set of functions that are O(n3)O(n^3)O(n3), but O(n3)=2n2O(n^3) = 2n^2O(n3)=2n2 is not valid.

  3. Explain the macro usage of Big O-notation, such as f(n)=n3+O(n2)f(n) = n^3 + O(n^2)f(n)=n3+O(n2).

    When O(n2)O(n^2)O(n2) appears on the right-hand side of an equation, it represents some function h(n)h(n)h(n) such that h(n)=O(n2)h(n) = O(n^2)h(n)=O(n2), and f(n)=n3+h(n)f(n) = n^3 + h(n)f(n)=n3+h(n). It essentially provides an error bound for the lower-order terms.

  4. What does it mean to have Big O-notation on the left-hand side, e.g., O(n2)=O(n3)O(n^2) = O(n^3)O(n2)=O(n3)?

    When O(n2)=O(n3)O(n^2) = O(n^3)O(n2)=O(n3) is written, it implies that for any function f(n)f(n)f(n) in the set O(n2)O(n^2)O(n2), that function f(n)f(n)f(n) is also in the set O(n3)O(n^3)O(n3). This maintains the asymmetric 'is' interpretation.

  5. Define Big Omega-notation, f(n)=Ω(g(n))f(n) = \Omega(g(n))f(n)=Ω(g(n)) and provide an example.

    It means there exist suitable constants ccc and n0n_0n0​ such that f(n)≥c⋅g(n)f(n) \ge c \cdot g(n)f(n)≥c⋅g(n) for all n≥n0n \ge n_0n≥n0​. It represents an asymptotic lower bound. An example is n=Ω(lg⁡n)\sqrt{n} = \Omega(\lg n)n​=Ω(lgn).

  6. What is the relationship between Big O, Big Omega, and Big Theta notation?

    Big O (OOO) represents 'less than or equal to' (upper bound), Big Omega (Ω\OmegaΩ) represents 'greater than or equal to' (lower bound), and Big Theta (Θ\ThetaΘ) represents 'equal to' (tight bound, meaning both an upper and lower bound).

  7. Distinguish between little o-notation (ooo) and little omega-notation (ω\omegaω).

    Little o (ooo) corresponds to 'strictly less than', meaning for every constant ccc, f(n)<c⋅g(n)f(n) < c \cdot g(n)f(n)<c⋅g(n) for sufficiently large nnn. Little omega (ω\omegaω) corresponds to 'strictly greater than', meaning for every constant ccc, f(n)>c⋅g(n)f(n) > c \cdot g(n)f(n)>c⋅g(n) for sufficiently large nnn. There is no little theta.

  8. What are the three main methods for solving recurrences in algorithm analysis?

    The three main methods are the substitution method, the recursion-tree method, and the master method.

  9. What is the primary drawback of the substitution method for solving recurrences?

    The primary drawback is that Step 1 is to guess the answer (or its form). Without a correct guess, the method cannot proceed to verify the solution by induction.

  10. Why is it important to avoid using Big O-notation directly within the substitution method's inductive step?

    Using Big O directly can lead to false proofs because the implicit constants in Big O can change with each inductive step, making the constant dependent on nnn instead of being a fixed value.

  11. When proving an upper bound T(n)=O(g(n))T(n) = O(g(n))T(n)=O(g(n)) using the substitution method, what is the 'residual' and what condition must it satisfy?

    The residual is the difference between the desired inductive step target (c⋅g(n)c \cdot g(n)c⋅g(n)) and what is derived from the expansion of T(n)T(n)T(n). For the induction to hold, the residual must be non-negative (greater than or equal to zero).

  12. What technique is often required to prove a tight upper bound, such as T(n)=O(n2)T(n) = O(n^2)T(n)=O(n2), for a recurrence like T(n)=4T(n/2)+nT(n) = 4T(n/2) + nT(n)=4T(n/2)+n using the substitution method?

    It often requires strengthening the induction hypothesis by subtracting lower-order terms. For T(n)=4T(n/2)+nT(n) = 4T(n/2) + nT(n)=4T(n/2)+n, instead of guessing T(n)≤cn2T(n) \le cn^2T(n)≤cn2, one might guess T(n)≤c1n2−c2nT(n) \le c_1n^2 - c_2nT(n)≤c1​n2−c2​n.

  13. Describe the intuition behind the recursion-tree method for solving recurrences.

    The recursion-tree method visualizes the recurrence as a tree, where each node represents the cost of a subproblem. The total cost is found by summing the costs at each level of the tree and then summing the costs of all levels.

  14. What is the main non-rigorous aspect of the recursion-tree method?

    The main non-rigorous aspect comes from the use of 'dot, dot, dots' to represent the continuation of the tree and summations, requiring careful justification or subsequent formal proof by substitution.

  15. 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 calculated using the recursion-tree method?

    The total cost is calculated by summing the non-recursive work at each level. The levels' costs are n2n^2n2, then (n/4)2+(n/2)2=(5/16)n2(n/4)^2 + (n/2)^2 = (5/16)n^2(n/4)2+(n/2)2=(5/16)n2, then (n/16)2+(n/8)2+(n/8)2+(n/4)2=(25/256)n2(n/16)^2 + (n/8)^2 + (n/8)^2 + (n/4)^2 = (25/256)n^2(n/16)2+(n/8)2+(n/8)2+(n/4)2=(25/256)n2, and so on. This forms a geometric series sum n2(1+5/16+25/256+… )n^2(1 + 5/16 + 25/256 + \dots)n2(1+5/16+25/256+…), which is O(n2)O(n^2)O(n2).

  16. What is the general form of recurrences that the Master Method can solve?

    The Master Method solves 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.

  17. What key function is compared against f(n)f(n)f(n) in the Master Method, and what does it represent in the recursion tree?

    The key function is nlog⁡ban^{\log_b a}nlogb​a. It represents the number of leaves in the recursion tree, up to a constant factor, or the cost at the bottom level of the recursion tree if each leaf incurs a constant cost.

  18. State Case 1 of the Master Method.

    If 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 (meaning f(n)f(n)f(n) is polynomially smaller than nlog⁡ban^{\log_b a}nlogb​a), then T(n)=Θ(nlog⁡ba)T(n) = \Theta(n^{\log_b a})T(n)=Θ(nlogb​a).

  19. State Case 2 of the Master Method.

    If f(n)=Θ(nlog⁡balg⁡kn)f(n) = \Theta(n^{\log_b a} \lg^k n)f(n)=Θ(nlogb​algkn) for some constant k≥0k \ge 0k≥0 (meaning f(n)f(n)f(n) is roughly equal to nlog⁡ban^{\log_b a}nlogb​a up to a polylogarithmic factor), then T(n)=Θ(nlog⁡balg⁡k+1n)T(n) = \Theta(n^{\log_b a} \lg^{k+1} n)T(n)=Θ(nlogb​algk+1n).

  20. State Case 3 of the Master Method.

    If f(n)=Ω(nlog⁡ba+ϵ)f(n) = \Omega(n^{\log_b a + \epsilon})f(n)=Ω(nlogb​a+ϵ) for some constant ϵ>0\epsilon > 0ϵ>0 (meaning f(n)f(n)f(n) is polynomially larger than nlog⁡ban^{\log_b a}nlogb​a), AND af(n/b)≤cf(n)af(n/b) \le cf(n)af(n/b)≤cf(n) for some constant c<1c < 1c<1 and all sufficiently large nnn (regularity condition), then T(n)=Θ(f(n))T(n) = \Theta(f(n))T(n)=Θ(f(n)).

  21. What kind of recurrence would the Master Method not apply to?

    The Master Method would not apply to recurrences like 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, because it has multiple subproblems of different sizes (n/4n/4n/4 and n/2n/2n/2). It also wouldn't apply if f(n)f(n)f(n) falls into the gaps between the cases (e.g., f(n)=nlog⁡ba/lg⁡nf(n) = n^{\log_b a} / \lg nf(n)=nlogb​a/lgn).

Card 1 of 21
Card 1 of 21

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent