Quiz 2

Recurrence Applications

119 words
1 min read
Python Week 1: the first filter for runtime behavior
Visual companion
Python
Type and operator map

Python Week 1: the first filter for runtime behavior

View
Revision summary

What this note is really saying

Short form

# Recurrence Applications ## Tower of Hanoi Number of moves $T_n = 2T_{n-1} + 1$, $T_1 = 1$. Solution: $T_n = 2^n - 1$.

Recurrence Applications

Tower of Hanoi

Number of moves Tn=2Tn1+1T_n = 2T_{n-1} + 1, T1=1T_1 = 1. Solution: Tn=2n1T_n = 2^n - 1. For n=64n = 64 disks: 26411.84×10192^{64} - 1 \approx 1.84 \times 10^{19} moves — about 585 billion years!

Divide-and-Conquer Recurrence

T(n)=aT(n/b)+f(n)T(n) = aT(n/b) + f(n) Master Theorem:
  • If f(n)=O(nlogbaϵ)f(n) = O(n^{\log_b a - \epsilon}), then T(n)=Θ(nlogba)T(n) = \Theta(n^{\log_b a})
  • If f(n)=Θ(nlogba)f(n) = \Theta(n^{\log_b a}), then T(n)=Θ(nlogbalogn)T(n) = \Theta(n^{\log_b a} \log n)
  • If f(n)=Ω(nlogba+ϵ)f(n) = \Omega(n^{\log_b a + \epsilon}) and af(n/b)cf(n)af(n/b) \leq cf(n), then T(n)=Θ(f(n))T(n) = \Theta(f(n)) Example: Merge sort: T(n)=2T(n/2)+nT(n) = 2T(n/2) + n. nlog22=n=f(n)n^{\log_2 2} = n = f(n), so T(n)=Θ(nlogn)T(n) = \Theta(n \log n). Join Discord PreviousRecurrence RelationsNextGenerating Functions
Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.