Office 416 Room 101 ?
6 questions, 4 hours. 6th question - about NP completeness.
Struggle with the problem.
Algorithms- Systematic method to solve a computational problem.
Turing Machine- Captures essence of a real computer. Makes precise the notion of problem, computing, solving, algorithm.
-
Makes one ask can every problem be solved ?- no
-
Even if we have infinite amount of time, some problems can't be solved.
-eg: Polynomial question x2 + y2 -xy +3 = 5 , does it have an int solution for x any y ? Ans: Turns out no. No algorithm. This problem is undecidable.
-
How fast can we solve it ? Computational complexity.
-
This is the thoery of Comp Sci.
Basic Algo Techniques
- Divide & Conquer
- Greedy
- Dynamic
- Amortized Analysis
Specific / Advanced ALgos
- Shortest Paths
- Max Flows
- Randomized Algos (allow for some possibility of error)
- Couple more if time allows.
- NP Completeness (define turning machine and formalise notions of what an algo is)
Pre Reqs: Practice proofs. Prove upper bound on running time. Proof by induction, contradiction, basic math.
-
Problem vs INstance size. eg: Problem- Sorting Instance- 1,5,4,3,5 Size - 5 (denoted by n)
-
How large is n ? Ans- It should be unbounded, as large as you want. We dont care about small n (not aqpplicable in real world so much)
-
"Algo should work for all n"
T(n) - Running Time. Running time measures number of "steps".
-
"constants are not imp" theoretically. Makes theory nicer. Makes theory nicer, asymptotic, "turing m/c step" is not defined.
-
if we start worrying about constants, we need to define what a step is.
Big O notation. T(n) = running time of algo, on input of size n. f(n) = n, n^2, nlogn (by default base 2 but doesnt really matter).
Defn: T(n) = O(f(n)) if there exists a constant C> 0 and integer n0 st n >= n0 T(n) <= C.f(n)
Functoin "grows" more rapidly than other.
EXERCISES Proof of: n^3 is asympotoitically small than O(2^n) n^50 is asympotoitically small than O(1.01^n)
n^2 + 5n + 100 <= n^2 + 5n^2 + 100n^2 = 106n^2.
Theorum: There is a sorting algorithm that runs in time O(nlogn). (Comparision Based Sorting)
Omega Notation:
T(n) = Omega(f(n)) if T(n) >= c.f(n). (get a Lower Bound) FOR c >0, n , such that for all n >= n0
You can prove lower bounds:
Theta Notation
T(n) = Theta(f(n)) if both T(n) = O(f(n)) and Omega(f(n)) hold true.
Rapid increase to the right. logn << log2n << sqrt(n) << n<< n^2 << 1.01^n<< 2^n<< 3^n <<....n! (or 2^(nlogn)) << 2^(2^n)