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

📊 Asymptotic Notation and Recurrence Relations

This lecture delves into the mathematical underpinnings of algorithm analysis, focusing on asymptotic notation for rigorous definition and methods for solving recurrence relations, which are crucial for analyzing recursive algorithms like Merge Sort.

📈 Asymptotic Notation: Defining Bounds

Asymptotic notation provides a way to describe the limiting behavior of functions, particularly the running time or space complexity of algorithms, as input size approaches infinity. It allows us to ignore constant factors and lower-order terms, focusing on the dominant growth rate.

🟠 Big O-Notation (OOO)

Big O-notation defines an upper bound for a function's growth.

  • Definition: f(n)=O(g(n))f(n) = O(g(n))f(n)=O(g(n)) means there exist positive constants ccc and n0n_0n0​ such that 0≤f(n)≤c⋅g(n)0 \le f(n) \le c \cdot g(n)0≤f(n)≤c⋅g(n) for all n≥n0n \ge n_0n≥n0​.

  • Intuition: f(n)f(n)f(n) grows no faster than g(n)g(n)g(n), or f(n)f(n)f(n) is "less than or equal to" g(n)g(n)g(n) asymptotically.

  • Example: 2n2=O(n3)2n^2 = O(n^3)2n2=O(n3) because for sufficiently large nnn, 2n22n^22n2 will always be less than or equal to c⋅n3c \cdot n^3c⋅n3 for a suitable constant ccc.

  • Asymmetry: The equality f(n)=O(g(n))f(n) = O(g(n))f(n)=O(g(n)) is asymmetric. 2n2=O(n3)2n^2 = O(n^3)2n2=O(n3) is true, but n3=O(2n2)n^3 = O(2n^2)n3=O(2n2) is false. This is because the notation implies "is a member of the set of functions bounded by".

    • More formally, f(n)∈O(g(n))f(n) \in O(g(n))f(n)∈O(g(n)), meaning f(n)f(n)f(n) is in the set of functions that are upper-bounded by g(n)g(n)g(n) up to a constant factor.

  • Usage as a Macro: Big O can be used within expressions to denote an error bound or a general function.

    • Example: f(n)=n3+O(n2)f(n) = n^3 + O(n^2)f(n)=n3+O(n2) means f(n)f(n)f(n) is roughly n3n^3n3, plus some lower-order terms that are bounded by O(n2)O(n^2)O(n2). This implies there exists a 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).

    • This allows for more refined statements about a function's behavior than just stating f(n)=O(n3)f(n) = O(n^3)f(n)=O(n3).

  • Left-hand Side Usage: When O(g(n))O(g(n))O(g(n)) appears on the left-hand side, it implies "for any expansion of the macro on the left, there is an expansion on the right such that equality holds."

    • Example: n2+O(n)=O(n2)n^2 + O(n) = O(n^2)n2+O(n)=O(n2) means that any function f(n)f(n)f(n) that is n2n^2n2 plus an O(n)O(n)O(n) term is also O(n2)O(n^2)O(n2). This is intuitive but highlights the asymmetry.

📉 Big Omega-Notation (Ω\OmegaΩ)

Big Omega-notation defines a lower bound for a function's growth.

  • Definition: f(n)=Ω(g(n))f(n) = \Omega(g(n))f(n)=Ω(g(n)) means there exist positive constants ccc and n0n_0n0​ such that 0≤c⋅g(n)≤f(n)0 \le c \cdot g(n) \le f(n)0≤c⋅g(n)≤f(n) for all n≥n0n \ge n_0n≥n0​.

  • Intuition: f(n)f(n)f(n) grows at least as fast as g(n)g(n)g(n), or f(n)f(n)f(n) is "greater than or equal to" g(n)g(n)g(n) asymptotically.

  • Example: n=Ω(lg⁡n)\sqrt{n} = \Omega(\lg n)n​=Ω(lgn) (log base 2 of nnn) because for sufficiently large nnn, n\sqrt{n}n​ will always be greater than or equal to c⋅lg⁡nc \cdot \lg nc⋅lgn for a suitable constant ccc.

⚖️ Big Theta-Notation (Θ\ThetaΘ)

Big Theta-notation defines a tight bound, indicating that a function's growth rate is exactly the same as another function, up to constant factors.

  • Definition: f(n)=Θ(g(n))f(n) = \Theta(g(n))f(n)=Θ(g(n)) means f(n)=O(g(n))f(n) = O(g(n))f(n)=O(g(n)) AND f(n)=Ω(g(n))f(n) = \Omega(g(n))f(n)=Ω(g(n)).

  • Intuition: f(n)f(n)f(n) grows at the same rate as g(n)g(n)g(n), or f(n)f(n)f(n) is "equal to" g(n)g(n)g(n) asymptotically, ignoring constant factors and lower-order terms.

  • Example: n2=Θ(2n2)n^2 = \Theta(2n^2)n2=Θ(2n2) because they differ only by a constant factor. Also, n2+O(n)=Θ(n2)n^2 + O(n) = \Theta(n^2)n2+O(n)=Θ(n2).

💨 Little o-Notation (ooo) and Little Omega-Notation (ω\omegaω)

These notations define strict bounds.

  • Little o-notation: f(n)=o(g(n))f(n) = o(g(n))f(n)=o(g(n)) means f(n)f(n)f(n) grows strictly slower than g(n)g(n)g(n).

    • Definition: For every constant c>0c > 0c>0, there exists an n0n_0n0​ such that 0≤f(n)<c⋅g(n)0 \le f(n) < c \cdot g(n)0≤f(n)<c⋅g(n) for all n≥n0n \ge n_0n≥n0​.

    • Intuition: f(n)f(n)f(n) is "strictly less than" g(n)g(n)g(n) asymptotically.

    • Example: n2=o(n3)n^2 = o(n^3)n2=o(n3).

  • Little omega-notation: f(n)=ω(g(n))f(n) = \omega(g(n))f(n)=ω(g(n)) means f(n)f(n)f(n) grows strictly faster than g(n)g(n)g(n).

    • Definition: For every constant c>0c > 0c>0, there exists an n0n_0n0​ such that 0≤c⋅g(n)<f(n)0 \le c \cdot g(n) < f(n)0≤c⋅g(n)<f(n) for all n≥n0n \ge n_0n≥n0​.

    • Intuition: f(n)f(n)f(n) is "strictly greater than" g(n)g(n)g(n) asymptotically.

    • Example: n3=ω(n2)n^3 = \omega(n^2)n3=ω(n2).

  • There is no "little theta" as strict equality doesn't have an asymptotic analog.


🌳 Solving Recurrences: Three Methods

Solving recurrence relations is fundamental for analyzing the running time of recursive algorithms. There isn't a single universal method, but rather a set of techniques.

1. 🔍 Substitution Method

The substitution method involves guessing a solution and then proving its correctness by mathematical induction.

  • Steps:

    1. Guess the form of the solution (e.g., O(n2)O(n^2)O(n2), Θ(nlg⁡n)\Theta(n \lg n)Θ(nlgn)). Often, you don't need to guess the exact constant factors.

    2. Verify by induction: Substitute the guessed solution (expanded with constants, e.g., cn2cn^2cn2) into the recurrence and prove that it holds for all n≥n0n \ge n_0n≥n0​ and for an appropriate choice of constants.

    3. Solve for constants: Determine the specific constants (ccc, n0n_0n0​) that make the induction work.

  • Caution: Avoid using Big O-notation directly within the inductive proof, as the implicit constants can change at each step, leading to invalid proofs. Always expand to explicit constants (e.g., T(n)≤cn2T(n) \le cn^2T(n)≤cn2).

  • Example Recurrence: T(n)=4T(n/2)+nT(n) = 4T(n/2) + nT(n)=4T(n/2)+n

    • Guess 1 (Upper Bound): T(n)=O(n3)T(n) = O(n^3)T(n)=O(n3)

      • Inductive Hypothesis: Assume T(k)≤ck3T(k) \le ck^3T(k)≤ck3 for all k<nk < nk<n.

      • Proof for T(n)T(n)T(n): T(n)=4T(n/2)+nT(n) = 4T(n/2) + nT(n)=4T(n/2)+n T(n)≤4c(n/2)3+nT(n) \le 4c(n/2)^3 + nT(n)≤4c(n/2)3+n (by inductive hypothesis) T(n)≤4c(n3/8)+nT(n) \le 4c(n^3/8) + nT(n)≤4c(n3/8)+n T(n)≤12cn3+nT(n) \le \frac{1}{2}cn^3 + nT(n)≤21​cn3+n

      • To show T(n)≤cn3T(n) \le cn^3T(n)≤cn3, we need 12cn3+n≤cn3\frac{1}{2}cn^3 + n \le cn^321​cn3+n≤cn3.

      • This simplifies to n≤12cn3n \le \frac{1}{2}cn^3n≤21​cn3, or 1≤12cn21 \le \frac{1}{2}cn^21≤21​cn2.

      • This holds for c≥2c \ge 2c≥2 and n≥1n \ge 1n≥1.

      • Base Case: For T(1)=constantT(1) = \text{constant}T(1)=constant, we need T(1)≤c(1)3T(1) \le c(1)^3T(1)≤c(1)3, which means ccc must be at least T(1)T(1)T(1). This is satisfied if we choose ccc large enough.

      • Result: T(n)=O(n3)T(n) = O(n^3)T(n)=O(n3) is a valid upper bound, but not tight.

    • Guess 2 (Attempting Tight Upper Bound): T(n)=O(n2)T(n) = O(n^2)T(n)=O(n2)

      • Inductive Hypothesis: Assume T(k)≤ck2T(k) \le ck^2T(k)≤ck2 for all k<nk < nk<n.

      • Proof for T(n)T(n)T(n): T(n)=4T(n/2)+nT(n) = 4T(n/2) + nT(n)=4T(n/2)+n T(n)≤4c(n/2)2+nT(n) \le 4c(n/2)^2 + nT(n)≤4c(n/2)2+n T(n)≤4c(n2/4)+nT(n) \le 4c(n^2/4) + nT(n)≤4c(n2/4)+n T(n)≤cn2+nT(n) \le cn^2 + nT(n)≤cn2+n

      • To show T(n)≤cn2T(n) \le cn^2T(n)≤cn2, we need cn2+n≤cn2cn^2 + n \le cn^2cn2+n≤cn2.

      • This simplifies to n≤0n \le 0n≤0, which is impossible for n≥1n \ge 1n≥1.

      • Problem: The "+ nnn" term prevents the direct inductive step from working. This indicates the induction hypothesis is too weak.

    • Guess 3 (Strengthened Hypothesis for Tight Upper Bound): T(n)=O(n2)T(n) = O(n^2)T(n)=O(n2) by assuming T(k)≤c1k2−c2kT(k) \le c_1k^2 - c_2kT(k)≤c1​k2−c2​k

      • Intuition: Subtracting a lower-order term (like c2kc_2kc2​k) can sometimes "absorb" the problematic additive terms in the recurrence.

      • Inductive Hypothesis: Assume T(k)≤c1k2−c2kT(k) \le c_1k^2 - c_2kT(k)≤c1​k2−c2​k for all k<nk < nk<n.

      • Proof for T(n)T(n)T(n): T(n)=4T(n/2)+nT(n) = 4T(n/2) + nT(n)=4T(n/2)+n T(n)≤4[c1(n/2)2−c2(n/2)]+nT(n) \le 4[c_1(n/2)^2 - c_2(n/2)] + nT(n)≤4[c1​(n/2)2−c2​(n/2)]+n T(n)≤4[c1n2/4−c2n/2]+nT(n) \le 4[c_1n^2/4 - c_2n/2] + nT(n)≤4[c1​n2/4−c2​n/2]+n T(n)≤c1n2−2c2n+nT(n) \le c_1n^2 - 2c_2n + nT(n)≤c1​n2−2c2​n+n T(n)≤c1n2−(2c2−1)nT(n) \le c_1n^2 - (2c_2 - 1)nT(n)≤c1​n2−(2c2​−1)n

      • To show T(n)≤c1n2−c2nT(n) \le c_1n^2 - c_2nT(n)≤c1​n2−c2​n, we need c1n2−(2c2−1)n≤c1n2−c2nc_1n^2 - (2c_2 - 1)n \le c_1n^2 - c_2nc1​n2−(2c2​−1)n≤c1​n2−c2​n.

      • This simplifies to −(2c2−1)n≤−c2n-(2c_2 - 1)n \le -c_2n−(2c2​−1)n≤−c2​n, or (2c2−1)n≥c2n(2c_2 - 1)n \ge c_2n(2c2​−1)n≥c2​n.

      • Dividing by nnn (assuming n>0n>0n>0): 2c2−1≥c22c_2 - 1 \ge c_22c2​−1≥c2​.

      • This yields c2≥1c_2 \ge 1c2​≥1.

      • Base Case: We need T(1)≤c1(1)2−c2(1)T(1) \le c_1(1)^2 - c_2(1)T(1)≤c1​(1)2−c2​(1). If T(1)T(1)T(1) is some constant, we can choose c1c_1c1​ sufficiently large (e.g., c1≥T(1)+c2c_1 \ge T(1) + c_2c1​≥T(1)+c2​) to satisfy this.

      • Result: By choosing c2≥1c_2 \ge 1c2​≥1 and c1c_1c1​ sufficiently large, T(n)=O(n2)T(n) = O(n^2)T(n)=O(n2) is proven.

2. 🌲 Recursion-Tree Method

The recursion-tree method involves drawing a tree that represents the recursive calls and the work done at each level, then summing the costs level by level.

  • Process:

    1. Draw the tree: Each node represents the cost of a subproblem. The root is the original problem. Children nodes represent recursive calls.

    2. Determine cost at each level: Sum the non-recursive work at each level of the tree.

    3. Determine tree height: Calculate the number of levels until the base case is reached.

    4. Determine number of leaves: Count the number of base case problems.

    5. Sum all costs: Add up the costs of all levels (including leaves) to get the total running time.

  • Non-Rigorous Aspect: This method often involves "..." (dot, dot, dots), making it less formal. It's excellent for guessing the solution, which can then be formally proven with the substitution method.

  • Example 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

    • Level 0 (Root): Cost = n2n^2n2

    • Level 1: Two recursive calls: T(n/4)T(n/4)T(n/4) and T(n/2)T(n/2)T(n/2). Costs = (n/4)2+(n/2)2=n2/16+n2/4=(1/16+4/16)n2=(5/16)n2(n/4)^2 + (n/2)^2 = n^2/16 + n^2/4 = (1/16 + 4/16)n^2 = (5/16)n^2(n/4)2+(n/2)2=n2/16+n2/4=(1/16+4/16)n2=(5/16)n2.

    • Level 2:

      • From T(n/4)T(n/4)T(n/4): T(n/16)T(n/16)T(n/16) and T(n/8)T(n/8)T(n/8). Costs = (n/16)2+(n/8)2=n2/256+n2/64=(1/256+4/256)n2=(5/256)n2(n/16)^2 + (n/8)^2 = n^2/256 + n^2/64 = (1/256 + 4/256)n^2 = (5/256)n^2(n/16)2+(n/8)2=n2/256+n2/64=(1/256+4/256)n2=(5/256)n2.

      • From T(n/2)T(n/2)T(n/2): T(n/8)T(n/8)T(n/8) and T(n/4)T(n/4)T(n/4). Costs = (n/8)2+(n/4)2=n2/64+n2/16=(4/256+16/256)n2=(20/256)n2(n/8)^2 + (n/4)^2 = n^2/64 + n^2/16 = (4/256 + 16/256)n^2 = (20/256)n^2(n/8)2+(n/4)2=n2/64+n2/16=(4/256+16/256)n2=(20/256)n2.

      • Total Level 2 cost = (5/256+20/256)n2=(25/256)n2(5/256 + 20/256)n^2 = (25/256)n^2(5/256+20/256)n2=(25/256)n2.

    • Observation: The costs at each level form a geometric series: n2n^2n2, (5/16)n2(5/16)n^2(5/16)n2, (25/256)n2(25/256)n^2(25/256)n2, ...

    • Summing the series: T(n)=n2(1+5/16+25/256+… )T(n) = n^2(1 + 5/16 + 25/256 + \dots)T(n)=n2(1+5/16+25/256+…). Since the common ratio (5/16)(5/16)(5/16) is less than 1, this is a decreasing geometric series. The sum is dominated by the first term.

    • Result: T(n)=Θ(n2)T(n) = \Theta(n^2)T(n)=Θ(n2).

3. 🧙 Master Method (Master Theorem)

The master method provides a direct solution for recurrences of a specific form. It's more precise and formal than recursion trees but is restricted to certain types of recurrences.

  • General Form: T(n)=aT(n/b)+f(n)T(n) = aT(n/b) + f(n)T(n)=aT(n/b)+f(n)

    • a≥1a \ge 1a≥1: Number of subproblems.

    • b>1b > 1b>1: Factor by which subproblem size is reduced.

    • f(n)f(n)f(n): Cost of dividing the problem and combining solutions (non-recursive work).

    • f(n)f(n)f(n) must be asymptotically positive (i.e., f(n)>0f(n) > 0f(n)>0 for sufficiently large nnn).

  • Key Comparison: The method compares f(n)f(n)f(n) with nlog⁡ban^{\log_b a}nlogb​a.

  • Three Cases:

    • Case 1: f(n)f(n)f(n) is polynomially smaller than nlog⁡ban^{\log_b a}nlogb​a

      • Condition: 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.

      • Solution: T(n)=Θ(nlog⁡ba)T(n) = \Theta(n^{\log_b a})T(n)=Θ(nlogb​a).

      • Intuition: The cost is dominated by the work done at the leaves of the recursion tree.

    • Case 2: f(n)f(n)f(n) is asymptotically equal to nlog⁡ban^{\log_b a}nlogb​a (up to polylogarithmic factors)

      • Condition: 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.

      • Solution: T(n)=Θ(nlog⁡balg⁡k+1n)T(n) = \Theta(n^{\log_b a} \lg^{k+1} n)T(n)=Θ(nlogb​algk+1n).

      • Intuition: The cost is roughly evenly distributed across all levels of the recursion tree. The lg⁡k+1n\lg^{k+1} nlgk+1n factor comes from multiplying the work per level by the number of levels (which is proportional to lg⁡n\lg nlgn).

    • Case 3: f(n)f(n)f(n) is polynomially larger than nlog⁡ban^{\log_b a}nlogb​a

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

      • Regularity Condition: Additionally, there must exist a constant c<1c < 1c<1 such that af(n/b)≤cf(n)af(n/b) \le c f(n)af(n/b)≤cf(n) for all sufficiently large nnn. This ensures that the non-recursive work decreases fast enough at each level.

      • Solution: T(n)=Θ(f(n))T(n) = \Theta(f(n))T(n)=Θ(f(n)).

      • Intuition: The cost is dominated by the work done at the root (top level) of the recursion tree.

  • Examples:

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

      • a=4,b=2,f(n)=na=4, b=2, f(n)=na=4,b=2,f(n)=n.

      • Compare f(n)=nf(n)=nf(n)=n with nlog⁡24=n2n^{\log_2 4} = n^2nlog2​4=n2.

      • n=O(n2−ϵ)n = O(n^{2 - \epsilon})n=O(n2−ϵ) for ϵ=1\epsilon=1ϵ=1. This is Case 1.

      • Solution: T(n)=Θ(n2)T(n) = \Theta(n^2)T(n)=Θ(n2).

    2. T(n)=4T(n/2)+n2T(n) = 4T(n/2) + n^2T(n)=4T(n/2)+n2

      • a=4,b=2,f(n)=n2a=4, b=2, f(n)=n^2a=4,b=2,f(n)=n2.

      • Compare f(n)=n2f(n)=n^2f(n)=n2 with nlog⁡24=n2n^{\log_2 4} = n^2nlog2​4=n2.

      • n2=Θ(n2lg⁡0n)n^2 = \Theta(n^2 \lg^0 n)n2=Θ(n2lg0n) (here k=0k=0k=0). This is Case 2.

      • Solution: T(n)=Θ(n2lg⁡0+1n)=Θ(n2lg⁡n)T(n) = \Theta(n^2 \lg^{0+1} n) = \Theta(n^2 \lg n)T(n)=Θ(n2lg0+1n)=Θ(n2lgn).

    3. T(n)=4T(n/2)+n3T(n) = 4T(n/2) + n^3T(n)=4T(n/2)+n3

      • a=4,b=2,f(n)=n3a=4, b=2, f(n)=n^3a=4,b=2,f(n)=n3.

      • Compare f(n)=n3f(n)=n^3f(n)=n3 with nlog⁡24=n2n^{\log_2 4} = n^2nlog2​4=n2.

      • n3=Ω(n2+ϵ)n^3 = \Omega(n^{2 + \epsilon})n3=Ω(n2+ϵ) for ϵ=1\epsilon=1ϵ=1. This is Case 3.

      • Check regularity condition: af(n/b)=4(n/2)3=4(n3/8)=12n3af(n/b) = 4(n/2)^3 = 4(n^3/8) = \frac{1}{2}n^3af(n/b)=4(n/2)3=4(n3/8)=21​n3.

        • Is 4f(n/2)≤cf(n)4f(n/2) \le c f(n)4f(n/2)≤cf(n)? Is 12n3≤cn3\frac{1}{2}n^3 \le c n^321​n3≤cn3? Yes, for c=1/2<1c=1/2 < 1c=1/2<1.

      • Solution: T(n)=Θ(n3)T(n) = \Theta(n^3)T(n)=Θ(n3).

    4. T(n)=4T(n/2)+n2/lg⁡nT(n) = 4T(n/2) + n^2/\lg nT(n)=4T(n/2)+n2/lgn

      • a=4,b=2,f(n)=n2/lg⁡na=4, b=2, f(n)=n^2/\lg na=4,b=2,f(n)=n2/lgn.

      • Compare f(n)=n2/lg⁡nf(n)=n^2/\lg nf(n)=n2/lgn with nlog⁡24=n2n^{\log_2 4} = n^2nlog2​4=n2.

      • f(n)f(n)f(n) is neither polynomially smaller nor polynomially larger, nor Θ(n2lg⁡kn)\Theta(n^2 \lg^k n)Θ(n2lgkn). It falls in the "gap" between Case 1 and Case 2. The Master Method does not apply.

💡 Intuition Behind the Master Method (Recursion Tree Sketch)

  • The height of the recursion tree is log⁡bn\log_b nlogb​n.

  • The number of leaves is alog⁡bn=nlog⁡baa^{\log_b n} = n^{\log_b a}alogb​n=nlogb​a.

  • Cost at levels:

    • Root: f(n)f(n)f(n)

    • Level 1: a⋅f(n/b)a \cdot f(n/b)a⋅f(n/b)

    • Level 2: a2⋅f(n/b2)a^2 \cdot f(n/b^2)a2⋅f(n/b2)

    • ...

    • Level kkk: ak⋅f(n/bk)a^k \cdot f(n/b^k)ak⋅f(n/bk)

    • Leaves: nlog⁡ban^{\log_b a}nlogb​a (each contributes a constant amount).

  • Case 1 (Leaf-dominated): If f(n)f(n)f(n) is polynomially smaller than nlog⁡ban^{\log_b a}nlogb​a, the sum of costs forms a geometrically increasing series, dominated by the last term (leaves).

  • Case 3 (Root-dominated): If f(n)f(n)f(n) is polynomially larger than nlog⁡ban^{\log_b a}nlogb​a (and satisfies the regularity condition), the sum of costs forms a geometrically decreasing series, dominated by the first term (root).

  • Case 2 (Evenly distributed): If f(n)f(n)f(n) is asymptotically equal to nlog⁡ban^{\log_b a}nlogb​a (up to polylog factors), the cost is roughly the same at all levels. The total cost is then approximately (cost per level) ×\times× (number of levels), resulting in the extra lg⁡n\lg nlgn factor.


Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent