Skip to content

Latest commit

 

History

History
55 lines (48 loc) · 3 KB

File metadata and controls

55 lines (48 loc) · 3 KB

Lecture 9: EEA, Modular Inverse & Merge Sort Complexity [09/02/2026]

Course: Advanced Data Structures and Algorithms


1. EEA: Algorithmic Refinement [00:00:51]

  • Goal: Find $x, y$ such that $ax + ny = GCD(a, n)$.
  • Iterative Derivation [00:18:10]:
    • Each remainder $R_i$ is a linear combination: $R_i = x_i a + y_i n$.
    • Using $R_i = R_{i-2} - q_i R_{i-1}$ (where $q_i = \lfloor R_{i-2} / R_{i-1} \rfloor$):
      • $x_i = x_{i-2} - q_i x_{i-1}$
      • $y_i = y_{i-2} - q_i y_{i-1}$
  • Initialization:
    • ($R_0=a, x_0=1, y_0=0$)
    • ($R_1=n, x_1=0, y_1=1$)
  • Result: When $R_i = 0$, $R_{i-1}$ is the GCD, and $x_{i-1}, y_{i-1}$ are the Bezout coefficients.

2. Multiplicative Inverse in Cryptography [00:33:40]

  • Definition: $a^{-1} \pmod n$ is the value $x$ such that $ax \equiv 1 \pmod n$.
  • Existence: $a^{-1} \pmod n$ exists if and only if $GCD(a, n) = 1$.
  • Calculation: Run EEA on ($a, n$). If $d=1$, then $x \pmod n$ is the inverse.
  • Applications [01:00:00]: Used in encryption/decryption (e.g., RSA), digital signatures, and blinding techniques.
  • Z*n: The set of integers ${1, 2, ..., n-1}$ that are relatively prime to $n$.

3. Merge Sort & Divide and Conquer [01:17:15]

  • History [01:21:40]: von Neumann (1945) introduced Merge Sort to demonstrate the superiority of the Stored Program Concept on his EDVAC-style machines over traditional mechanical punch-card sorters.
  • Algorithm (Divide and Conquer):
    1. Divide: Split array into two halves at $q = \lfloor n/2 \rfloor$.
    2. Conquer: Recursively MergeSort both halves.
    3. Combine: Merge the two sorted halves in $O(n)$ time.
  • Merge Logic [01:46:27]: Compare the heads of two sorted lists. Pull the minimum and advance that list's pointer. If one list exhausts, copy the remainder of the other.

4. Formal Complexity Analysis [02:10:55]

  • Recurrence Relation: $$T(n) = T(\lfloor n/2 \rfloor) + T(\lceil n/2 \rceil) + (n-1)$$
  • Solving for $n = 2^k$:
    • Dividing by $2^k$: $S_k = S_{k-1} + 1$ (approx).
    • $S_k = k$.
    • $T(2^k) = 2^k \cdot k = n \log n$.
  • Smoothness Assumption [02:21:22]: We assume $T(n)$ grows predictably between powers of 2, thus $T(n) \in \Theta(n \log n)$ for all $n$.

5. Administrative & Resources [01:07:56]

  • Textbooks:
    • CLRS (Cormen): Recommended for rigorous math and RSA details.
    • Jeff Erickson: Highly recommended for clear pseudo-code and intuitive logic.
  • Warning on Attendance [02:38:09]: The instructor expresses deep concern over falling attendance (~35 students present). He warns that these concepts are difficult to learn through self-study and that missing classes could lead to disqualification from the final exam.

Key Terms Corrected:

  • bis out identity -> Bezout's Identity
  • u plates algorithm -> Euclidean Algorithm
  • Horacea -> RSA
  • Revist Shamir Adelman -> Rivest, Shamir, and Adleman
  • Lomato partition -> Lomuto Partition
  • heave sort -> Heap Sort