BIT152 ยท 2081 ยท 10 marks
What are the uses of randomized algorithm? Find the solution to the recurrence relation an = 6an-1 - 11an-2 + 6an-3 with the initial conditions a0 = 2, a1 = 5 and a2 = 15. [2+8]
What are the uses of randomized algorithm? Find the solution to the recurrence relation $a_n = 6a_{n-1} - 11a_{n-2} + 6a_{n-3}$ with the initial conditions $a_0 = 2$, $a_1 = 5$ and $a_2 = 15$. [2+8]
Uses of Randomized Algorithms [2 marks]
A randomized algorithm uses random choices during its execution to influence its behavior. Common uses include:
- Primality Testing - Fast probabilistic tests such as Miller-Rabin and Solovay-Strassen for very large numbers.
- Randomized Quicksort - Random pivot selection gives expected $O(n\log n)$ time and avoids adversarial worst cases.
- Cryptography - Generating random keys, nonces, salts, and initialization vectors.
- Approximation / Monte Carlo Methods - Quick approximate solutions to hard (NP-hard) or numerical problems.
- Load Balancing / Distributed Systems - Randomly assigning tasks to balance load.
- Hashing - Universal and cryptographic hashing to reduce collisions.
Solving the Recurrence Relation [8 marks]
Given data
- Recurrence: $a_n = 6a_{n-1} - 11a_{n-2} + 6a_{n-3}$
- $a_0 = 2,\quad a_1 = 5,\quad a_2 = 15$
Step 1: Characteristic Equation
Assume $a_n = r^n$: $$r^3 = 6r^2 - 11r + 6$$ $$r^3 - 6r^2 + 11r - 6 = 0$$
Step 2: Roots
Test $r=1$: $1 - 6 + 11 - 6 = 0$ โ
$$r^3 - 6r^2 + 11r - 6 = (r-1)(r^2 - 5r + 6) = (r-1)(r-2)(r-3)$$
Roots: $r_1 = 1,\ r_2 = 2,\ r_3 = 3$ (distinct).
Step 3: General Solution
$$a_n = A(1)^n + B(2)^n + C(3)^n = A + B\cdot 2^n + C\cdot 3^n$$
Step 4: Apply Initial Conditions
$$n=0:\ A + B + C = 2 \quad (1)$$ $$n=1:\ A + 2B + 3C = 5 \quad (2)$$ $$n=2:\ A + 4B + 9C = 15 \quad (3)$$
Solution
$(2)-(1):\ B + 2C = 3 \quad (4)$ $(3)-(2):\ 2B + 6C = 10 \Rightarrow B + 3C = 5 \quad (5)$ $(5)-(4):\ C = 2$ From $(4):\ B = 3 - 4 = -1$ From $(1):\ A = 2 - (-1) - 2 = 1$
So $A=1,\ B=-1,\ C=2$.
Final Answer
$$\boxed{a_n = 1 - 2^n + 2\cdot 3^n}$$
Verification
| $n$ | $1 - 2^n + 2\cdot3^n$ | Expected |
|---|---|---|
| 0 | $1 - 1 + 2 = 2$ | 2 โ |
| 1 | $1 - 2 + 6 = 5$ | 5 โ |
| 2 | $1 - 4 + 18 = 15$ | 15 โ |
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.