CS 517
Table of Contents
1. CS 317
[Catalog]
- Introduction to complexity analysis of algorithms
- Emphasis on
- searching
- sorting
- finding spanning trees
- finding shortest paths in graphs
- Design techniques such as
- divide & conquer
- dynamic programming
- backtracking
- Introduction to problem classification; i.e. NP, intractable, and unsolvable.
2. CS 517
[Catalog]
Intensive introduction to computing theory selected core topics from the undergraduate Computer Science curriculum, including
- Boolean algebra
- digital logic
- proof methods
- recursion and recurrences
- graphs and trees
- iterative and recursive algorithms
- sorting and searching algorithms
- divide-and-conquer algorithms
3. Algorithmic Analysis
3.1. Efficiency/Complexity Analysis
- Time
- Space
3.1.1. Input Size
Measured in terms of input size:
- Array: number of items
- Trees: number of nodes, height of tree
- String: number of characters
- Polynomials: order of polynomial
3.1.2. Basic Operations
Count the # of basic operations:
+, -, *, /~ are usually considered basic operations with cost 1 (\(c_{op}\))
3.1.3. Order of Growth
In practise we ignore \(c_{op}\) , only consider order of growth
Efficiency Class | Order of Growth |
---|---|
constant | 1 |
logarithmic | \(\log{n}\) |
linear | \(n\) |
linearithmic | \(n \log {n}\) |
exponential | \(2^n\) |
- Comparing order of growth
\begin{equation} \label{eqn:order-of-growth} \lim_{n \to \infty} \frac{t(n)}{g(n)} \tag{order-of-growth} \end{equation}- 0 => \(t(n)\) has smalleer order of growth than \(g(n)\)
- \(c\) => Order of growth is equal
- \(\infty\) implies \(t(n)\) has higher order of growth than \(g(n)\)
3.1.4. Asymptotic Notation
\(O\) Big-O: Bounded from above
\(t(n) \in O(g(n)) \textrm{ if } t(n) \leq c g(n) \; \forall n \geq n_0\)
\(\Omega\) Big-Omega: Bounded from below
\(t(n) \in \Omega(g(n)) \textrm{ if } t(n) \geq c g(n) \; \forall n \geq n_0\)
\(\Theta\) Big-Theta: Bounded from above and below
\(t(n) \in \Omega(g(n)) \textrm{ if } c_1 g(n) \leq t(n) \leq c_2 g(n) \; \forall n \geq n_0\)
\(o\) Small-O: Bounded from above for all constants c
\(t(n) \in o(g(n)) \textrm{ if } \forall c > 0 \; \exists n_0 : t(n) < c g(n) \; \forall n \geq n_0\)
\begin{equation*}
limn → ∞ \frac {t(n)} {g(n)} = 0 \end{equation*}
\(\omega\) Small-omega: Bounded from below for all constants c
\(t(n) \in \omega(g(n)) \textrm{ if } \forall c > 0 \; \exists n_0 : t(n) > c g(n) \; \forall n \geq n_0\)
\begin{equation*} lim_{n \to \infty} \frac {t(n)} {g(n)} = \infty \end{equation*}
Note that \(t(n) > 0\)
\(f(n) = O(g(n))\) | \(a \leq b\) |
\(f(n) = o(g(n))\) | \(a < b\) |
\(f(n) = \Theta(g(n))\) | \(a = b\) |
\(f(n) = \omega(g(n))\) | \(a > b\) |
\(f(n) = \Omega(g(n))\) | \(a \geq b\) |
3.1.5. Structure of Input
Slide 2 - Page 3 Efficiency is not only dependent on input size, structure of input mattes too.
- Worst case
- Best case
- Average case
- Amortized
3.1.6. Useful Tricks
3.2. Recursive(-like) functions
Functions whose complexity is defined in terms of itself.
Three methods for solving Recurrence Relations Slide 2 - Page 13
3.2.1. Backward/Forward Substitution
3.2.2. Characteristic Equation
- Works only for linear homogeneous recurrence
- Bring all terms of recurrence relation to LHS
- Write the characteristic equation (convert ai term to ri terms)
- Solve the equation
- According to nature of roots, the form of the solution is known
Good for linear homogeneous whose characteristic equation is quadrati
3.2.3. Master Theorem
- Slide 3 - Page 3
- https://en.wikipedia.org/wiki/Master_theorem_(analysis_of_algorithms)
- For analysis of divide-and-conqure algorithms.
- Its generalization is Akra-Bazzi Method
- \(f(n)\) is the time taken to split the problem and recombine the solution
- One assumption is that at some \(n \leq \kappa \; ; \kappa > 0\), the solutions doesn't have to recurse i.e \(f(n) = \Theta(1) \; n \leq \kappa\)