Skip to content

Latest commit

 

History

History
48 lines (41 loc) · 3.18 KB

File metadata and controls

48 lines (41 loc) · 3.18 KB

Lecture 8: GCD Complexity & Extended Euclidean Algorithm [04/02/2026]

Course: Advanced Data Structures and Algorithms


1. Paradigm Review: Decrymental Design in Number Theory [00:00:29]

The instructor emphasizes that we shouldn't just write any solution; we must "think deeply" to arrive at breakthroughs.

  • Decrymental Design (Value-Based): Unlike searching where we prune the subset, in number theory, we decrement the numerical value until a base case (0 or equality) is reached.

2. The Euclidean Algorithm for GCD [00:04:30]

  • Foundations:
    • $GCD(A, B) = GCD(A, A-B)$ because any divisor of $A$ and $B$ must also divide $A-B$.
    • This can be generalized to $GCD(A, B) = GCD(B, A \pmod B)$.
  • Implementations:
    • Iterative: while (b > 0) { temp = a % b; a = b; b = temp; } return a;
    • Recursive: if (b == 0) return a; else return gcd(b, a % b);
  • History [00:39:07]: Known for over 2,000 years, but its exact complexity remained elusive for most of that time.

3. Complexity Analysis: The log-Bound [00:41:08]

  • The Challenge: Input size is not "2" (the count of items), but $\log A$ (the number of bits).
  • The Half-Reduction Property [00:50:04]:
    • Lemma: In every two iterations of the Euclidean algorithm, the first component $A$ is reduced by at least a factor of two ($A_{i+2} < A_i / 2$).
    • Proof:
      • If $B \le A/2$, then $A \pmod B < B \le A/2$.
      • If $B > A/2$, then $A \pmod B = A - B < A/2$.
  • Result: Since the value halves every two steps, the total number of iterations is $O(\log A)$. This proves it is a Linear Time Algorithm relative to the input bit-size.
  • Lamé's Theorem [00:58:03]: A tighter bound was discovered in the 19th century relating GCD iterations to Fibonacci numbers and the Golden Ratio. For $n$-digit numbers, it takes at most $\approx 5n$ iterations.

4. Bezout's Identity & The Extended Algorithm [01:02:42]

  • Bezout's Identity: For any integers $A, B$, there exist integers $X, Y$ such that $AX + BY = GCD(A, B)$.
  • Significance: Core foundation of cryptography, particularly for finding modular inverses in RSA and Elliptic Curve Cryptography.
  • Extended Euclidean Algorithm (EEA) [01:07:33]:
    • Co-computes $X, Y$ alongside the GCD ($D$).
    • Iterative Logic [01:13:34]: Track a series of remainders $R_i$ where $R_0=A$, $R_1=B$, and $R_i = R_{i-2} \pmod{R_{i-1}}$.
    • The goal is to express each $R_i$ as a linear combination of $A$ and $B$.

5. Administrative: Background Context [01:08:16]

  • Diverse Audience: The instructor acknowledges a split in the class—half have done Cryptography/Discrete Math, half have not.
  • Deliberate Repetition: Certain foundational concepts will be repeated to ensure everyone is on the same page.
  • Technical Note [01:23:41]: The instructor confirms that iPad OneNote has disabled local export/mailing, which is why handwritten notes haven't been shared yet.

Key Terms Corrected:

  • Euclids algorithm -> Euclidean Algorithm
  • decriminal design -> Decrymental Design
  • Bezout identity -> Bezout's Identity
  • Lamei theorem -> Lamé's Theorem
  • iterative reminder -> Iterative Remainder Model