Design and Analysis of Algorithms · Unit 7 · 5 hrs
Number Theoretic Algorithms
Exam-focused notes for Number Theoretic Algorithms (Design and Analysis of Algorithms, CSC325): what the TU syllabus asks and how it has actually been tested, with 4 solved past questions from this unit.
Number Theoretic Algorithms in short
Number theoretic algorithms underlie modern cryptography and hashing: this unit covers the divisibility notation the rest of the topic is written in, Euclid's algorithm and its extended form, how to solve modular linear equations and simultaneous congruences, and a fast randomized way to test primality.
What this unit covers
- Number Theoretic Notations, Euclid's and Extended Euclid's Algorithms and their Analysis
- Solving Modular Linear Equations, Chinese Remainder Theorem, Primility Testing: Miller-Rabin Randomized Primility Test and their Analysis
Number Theoretic Notations, Euclid's and Extended Euclid's Algorithms and their Analysis
2082 · 5 marks
Using Extended Euclidean Algorithm, find the GCD of 12 and 16. [5]
Show solved answerHide answer
Extended Euclidean Algorithm: GCD of 12 and 16
Given
- First integer: $a = 16$ (larger)
- Second integer: $b = 12$
Goal: Find $\gcd(16, 12)$ and integers $x, y$ such that $16x + 12y = \gcd(16,12)$.
Solution
Forward Pass (Euclidean Algorithm)
| Step | Division | Quotient $q$ | Remainder $r$ |
|---|---|---|---|
| 1 | $16 = 12 \times 1 + 4$ | 1 | 4 |
| 2 | $12 = 4 \times 3 + 0$ | 3 | 0 |
The last non-zero remainder is $4$, so:
$$\gcd(16, 12) = 4$$
Back-Substitution (Extended Part)
Express the GCD as a linear combination $16x + 12y = 4$.
From Step 1:
$$4 = 16 - 12 \times 1$$
Rearranging:
$$4 = 16 \times (1) + 12 \times (-1)$$
Therefore:
$$x = 1, \quad y = -1$$
Verification
$$16 \times (1) + 12 \times (-1) = 16 - 12 = 4 \checkmark$$
Also confirming GCD independently: divisors of 12 are ${1,2,3,4,6,12}$, divisors of 16 are ${1,2,4,8,16}$; the greatest common divisor is indeed $4$.
Result
| Result | Value |
|---|---|
| $\gcd(12, 16)$ | $4$ |
| Coefficient $x$ (for 16) | $1$ |
| Coefficient $y$ (for 12) | $-1$ |
| Bezout identity | $16(1) + 12(-1) = 4$ |
2080 · 5 marks
Why extended euclidean algorithm is used? Write down its algorithm and analyze its complexity. [5]
Solving Modular Linear Equations, Chinese Remainder Theorem, Primility Testing
2081 · 5 marks
Solve the following linear equation using Chinese Remainder Theorem. x = 1 MOD 3,x = 2 MOD 5,x = 0 MOD 7 [5]
2079 · 5 marks
Solve the following linear congruences using Chinese Remainder Theorem.x≡1(mod2),x≡3(mod5),x≡6(mod7)x \equiv 1 \pmod{2},\quad x \equiv 3 \pmod{5},\quad x \equiv 6 \pmod{7}x≡1(mod2),x≡3(mod5),x≡6(mod7) [5]
Make Unit 7 stick
Practice CSC325 with flashcards & quizzes