classnotes RTX 4070 Ti SUPER · faster-whisper · DeepSeek

5101 - Design & Analysis of Algo

← 5101 - Design & Analysis of Algo

DAA_30 Aug

Date 2026-08-30 Length 1h 26m Words 9,962 Segments 564
⤓ Download transcript (.txt with timestamps) ⤓ Plain transcript (.txt) ⤓ Transcript (.md)

Summary


session: "5101-design-analysis-of-algo/2026-08-30 0000 DAA 30 Aug"

title: "DAA 30 Aug"

date: "2026-08-30 00:00"

duration: "1h 26m"

language: "en"

model: "deepseek-ai/DeepSeek-V4.1-Flash-1017"

parts: 2

transcript_chars: 49999

generated: "2026-11-23T23:31:34+05:30"


DAA 30 Aug

Overview

This class completes the recap of algorithm-analysis principles (sequential, selection and iterative logic; analysis as a function of input size; dominating operation; search space and best/average/worst cases) and moves into growth of functions and asymptotic analysis. The main focus is Theta notation (sandwich notation): its formal condition, how to choose g(n), how to compute c₁, c₂ and n₀, and why f(n)/g(n) → 1 as n → ∞ is a mandate condition. Worked examples include 3n + 3, 18n + 9, 3n² − 9n + 17 and ½n² − 3n, plus a general quadratic formula for c₁, c₂, n₀. The class closes with the practical applicability of asymptotic analysis and course logistics; insertion sort and the remaining notations (big O, big Omega, little o, little omega) are deferred.

Learning outcomes

Core concepts

Three types of logic

Algorithm analysis as a function of input size

Any algorithm analysis is performed by assuming the algorithm as a function of input size, f(n). Input size is always a positive integer; as input size increases, the computational complexity of the algorithm increases. The analysis is theoretical and platform independent — it does not depend on which machine the code is run on.

Dominating operation

To determine computational complexity we must think about the key/dominating operation in the algorithm, e.g. the number of comparisons in searching and sorting algorithms. Multiplication dominates over addition and subtraction. In this course, algorithms primarily using searching or sorting concepts will be seen.

Search space and best/average/worst cases

The search space is the set of elements for sorting, or the array where the key value has to be identified; it plays a crucial role in determining best, average and worst case complexity.

Well-known functions g(n)

Well-known functions are those everyone knows — n², n³, n log n, log n, 2ⁿ — represented by the symbol g(n). f(n) represents the algorithm in terms of input size n; the aim is to identify the computational complexity of an algorithm closer to g(n), i.e. to reach a situation where f(n) can be represented in the form of g(n).

Efficiency ordering

If computational complexity goes towards log n, the algorithm is more efficient. For input size 100, the number of key operations is only 7 for log n, whereas for 2ⁿ it is 10³⁰. In the case of trees and graphs, the complexity touches log n — that is the beauty of these data structures and why they are very popular.

Asymptotic analysis

Identifying the behavior of the algorithm when n is very very large, i.e. when n tends to infinity. Motivation: an algorithm/website may tolerate a simultaneous hit of 5000 persons and work fine when tested for 10, 20, 30, 1000, 1500, 2000, but start failing or showing delays at 10,000 — we cannot check behavior for a varied set of inputs, so we determine behavior as n tends to infinity.

Asymptotic notations

Big O, big Omega, big Theta, little o, little omega. Big O, big Omega and theta are only for representation/nomenclature; the basic idea is to establish how the algorithm behaves. If we can identify what order the algorithm follows, we can declare it in theta, big O, or big Omega notation.

Theta notation (sandwich notation)

Theta notation is also known as the sandwich notation because the function is bounded by c₁ and c₂ on both sides (upper and lower bound). Theta notation best represents the average case. The mandate condition is f(n)/g(n) = 1 when n tends to infinity — i.e., f(n) and g(n) are "very similar to each other." If this fails (e.g., comparing 3n + 3 with n², which forces c₁ ≤ 0), the Theta condition is violated.

Why f(n) must be positive

There is no algorithm whose computational complexity decreases with increase in input size; any algorithm's complexity increases with input size. Hence the target is to identify a positive function that best represents the algorithm.

n₀

n₀ is a specific value beyond which the function f(n) is positive and we are certain the claimed behavior persists throughout (till infinity). Before n₀ we cannot claim the behavior will persist. The target is to make the function monotonically increasing so that the established computational complexity is valid till infinity. n₀ is not given; it must be determined. n₀ = 0 is not taken because n is the number of inputs to the algorithm and the algorithm accepts at least one input; analyzing behavior at input size zero has no significance.

Negative highest-degree term

If the highest-degree term is negative in any condition, asymptotic analysis cannot be performed, because ultimately the function is negative.

Applicability

The analysis is directly applicable to algorithms where the dominating operation is comparison (insertion sort, selection sort, merge sort, binary search, bucket sort). For operations like multiplication or tensor multiplication in ML/AI, the same ideas apply with modification — f(n) may be of order n⁴ etc. The general behavior is the same: complexity increases with input size. The analysis identifies the nature of the algorithm (quadratic, linear, logarithmic, cubic, etc.) and creates a base to determine computational complexity of any known algorithm; one must identify the segments/components imposing computational complexity.

Formulas and maths

Theta condition:

$$c_1 g(n) \le f(n) \le c_2 g(n) \quad \text{for all } n \ge n_0$$

c₁, c₂ are positive constants and n₀ is the threshold beyond which the bound holds. Used to establish f(n) = Θ(g(n)).

Set membership:

$$f(n) \in \Theta(g(n))$$

Read as "f of n is theta of g of n." Since many positive values of c₁ and c₂ can be taken, all such answers are correct — there is no fixed c₁, c₂.

Mandate condition for choosing g(n):

$$\lim_{n \to \infty} \frac{f(n)}{g(n)} = 1$$

Used to check that g(n) resembles f(n) even for very large n; e.g. for 18n + 9, n² is never considered because f(n)/g(n) will never equal 1 as n → infinity.

Determining c₁, c₂ (example 3n + 3, g(n) = n):

$$c_1 n \le 3n + 3 \le c_2 n \;\Rightarrow\; c_1 \le \frac{3n+3}{n}$$

Taking the limit n → infinity gives 3 (since something by infinity is 0), so c₁ ≤ 3; c₂ > 3. Used to pick concrete constants (chosen: c₁ = 2, c₂ = 4; fractional positive values are allowed).

Determining n₀:

$$3n + 3 = 0 \Rightarrow n = -1; \qquad 3n - 3 = 0 \Rightarrow n = 1$$

Solving where the function becomes positive gives the threshold. If f(n) is positive, n₀ = 1. If f(n) = 3n − 3, at n = 1 it is 0 and at n = 2 it becomes positive, so n₀ = 2. For 18n − 72, n must be greater than 4 (n = 5) for the function to become positive.

Example 18n + 9 with g(n) = 3n:

$$c_1 \cdot 3n \le 18n + 9 \le c_2 \cdot 3n \;\Rightarrow\; c_1 \le \frac{18n+9}{3n} = 6 + \frac{3}{n}$$

As n → infinity this tends to 6, so c₁ can be 6 or less; c₂ is one value higher. Used to conclude 18n + 9 = Θ(3n); if 3n were not given, it is equivalent to n.

Failure of g(n) = n² for f(n) = 3n + 3:

$$c_1 < \frac{3n+3}{n^2} = \frac{3}{n} + \frac{3}{n^2}$$

As n → ∞, c₁ ≤ 0 — fails (c₁ must be positive). Used to show n² is not a valid g(n).

Upper bound for 3n + 3 with g(n) = n:

$$3n + 3 \le c_2 n \;\Rightarrow\; c_2 \ge \frac{3n+3}{n} = 3 + \frac{3}{n}$$

As n → ∞, c₂ ≥ 3; any value ≥ 3 works (e.g. c₁ = 2 or anything, for computational ease). Used to fix the upper constant.

f(n) = 3n² − 9n + 17:

$$c_1 < 3 - \frac{9}{n} + \frac{17}{n^2}$$

So c₁ should be less than 3; example choice c₂ = 2 [as transcribed]. Used to conclude 3n² − 9n + 17 = Θ(n²) for all n₀ ≥ 3, with c₁, c₂ any positive values estimated beyond n₀ > 3.

½n² − 3n = Θ(n²):

$$c_1 < \tfrac{1}{2}, \quad c_2 > \tfrac{1}{2}, \quad n > 7$$

Used to establish the Theta bound for this expression.

Quadratic formula (for a quadratic expression with coefficients a, b, c), applicable only when a > 0 (the high-order term must have a positive constant):

$$c_1 = \frac{a}{4}, \qquad c_2 = \frac{7a}{4}, \qquad n_0 = 2 \cdot \max\left(\frac{|b|}{a}, \frac{|c|}{a}\right)$$

Stated as "2 into max of mod b irrespective of the sign by a and ... mod c by a" (with a comma between the two terms). Used to read off constants directly for quadratics; do not cram the formula — the technique shown is more than enough.

Cost evaluation:

$$f(n) = 3n + 3: \quad n = 100 \Rightarrow 300 + 3; \quad n = 10{,}000 \Rightarrow 3{,}000 + 3$$

Used to show the concrete cost at a given input size.

Worked examples

Questions asked in class

A: If it is not given, you have to consider n; otherwise it will be explicitly given.

A: After n₀, if f(n) is positive, we are sure the claim remains the same throughout. Before n₀ we cannot claim the behavior will persist. E.g. for 18n − 72, n must be greater than 4 (n = 5) for the function to become positive. We identify a value beyond which the function is positive and we are certain that the determined c₁, c₂ are correct; otherwise the condition may fail because we are dealing with a negative function.

A: n is the input size — the entire search space on which the operation is performed (e.g. 20 elements to search a key in; 100 numbers for searching or sorting). f(n) denotes the entire cost the algorithm consumes (e.g. 3n

Transcript

One line per segment, [hh:mm:ss] timestamp first.

loading…