diff --git a/docs/2a/ece250.md b/docs/2a/ece250.md index 9392a1d..de13090 100644 --- a/docs/2a/ece250.md +++ b/docs/2a/ece250.md @@ -1,5 +1,14 @@ # ECE 250: DSA +## Solving recurrences + +The **master method** is used to solve recurrences. For expressions of the form $T(n)=aT(n/b)+f(n)$: + +- If $f(n)=O(n^{\log_b a})$, we have $T(n)=\Theta(n^{\log_b a}\log n)$ +- If $f(n) < O(n^{\log_b a})$, we have $T(n)=O(n^{\log_b a})$ +- If $f(n) > \Omega(n^{\log_b a})$, and $af(n/b)\leq cf(n), c<0$, we have $T(n)=\Theta(f(n))$ + + ## Heaps A heap is a binary tree **stored in an array** in which all levels but the lowest are filled. It is guaranteed that the parent of index $i$ is greater than or equal to the element at index $i$.