Algorithm Design
Description:
Steps:
- Formulate the problem precisely
- Design an algo rithm
- Prove the algorithm is correct
- Analyze its runtime
Algothrm design techniques:
Complexity:
- An algorithm is efficient if its running time is a polynomial in the input size T
- The running time is upper bounded by c.Td for some constants c,d>0
- ex: brute force can solve Gale Shapley Algorithm in n!
- 2 main complexities:
Algorithmβs running time:
- To measure a Efficient Algorithm
- f(n) is asymptotically bounded by g(n)
- Propositions:
- if nββlimβg(n)f(n)β=c for some constant c>0 then f(n)=Ξ(g(n))
- Proof: cβΟ΅β€g(n)f(n)ββ€c+Ο΅ by definition
- (cβΟ΅)g(n)β€f(n)β€(c+Ο΅)g(n)
- by definition of Big Theta notation, it is true
- if nββlimβg(n)f(n)β=0 then f(n)=O(g(n))
- if nββlimβg(n)f(n)β=β then f(n)=Ξ©(g(n))
- To find which notation a function belongs to, do g(n)f(n)β
Some classes of function:
- Polynomials:
- f(n)=βk=0dβakβnk=O(nd),adβ>0
- as nββlimβndf(n)β=adβ>0
- Logarithms:
- logaβ(n)=Ξ(logbβn) for every a>1 and b>1
- as nββlimβlogbβnlogaβnβ=logbβa1β=c
- Logarithms and Polynomials:
- logaβn=O(nd) for every a>1 and every d>0
- as nββlimβndlogaβnβ=0
- Exponentials:
- nd=O(rn) for every r>1 and every d>0
- as nββlimβrnndβ=0
- Factorials: