 Download Presentation Relevant Mathematics Relevant Mathematics - PowerPoint PPT Presentation

Download Presentation Relevant Mathematics
An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

1. Thinking about Algorithms Abstractly Relevant Mathematics Classifying Functions The Time Complexity of an Algorithm Adding Made Easy Recurrence Relations Lecture2

2. Classifying Functions Time Complexity t(n) = Q(n2) f(i) = nQ(n) Time Input Size Recurrence Relations Adding Made Easy T(n) = a T(n/b) + f(n) ∑i=1 f(i). Start With Some Math

3. Assumed Knowledge Read the section on • Existential and Universal Quantifiers, • Logarithms and Exponentials g "b Loves(b,g)"b g Loves(b,g)

4. Classifying Functions Giving an idea of how fast a function grows without going into too much detail.

5. Which are more alike?

6. Which are more alike? Mammals

7. Which are more alike?

8. Classifying Animals Vertebrates Fish Reptiles Mammals Birds Dogs Giraffe

9. T(n) 10 100 1,000 10,000 log n 3 6 9 13 amoeba n1/2 3 10 31 100 bird 10 100 1,000 10,000 human n log n 30 600 9,000 130,000 my father n2 100 10,000 106 108 elephant n3 1,000 106 109 1012 dinosaur 2n 1,024 1030 10300 103000 the universe Classifying Functions n Note: The universe contains approximately 1050 particles.

10. Which are more alike? n1000 n2 2n

11. Which are more alike? n1000 n2 2n Polynomials

12. Which are more alike? 1000n2 3n2 2n3

13. Which are more alike? 1000n2 3n2 2n3 Quadratic

14. Classifying Functions? Functions

15. 25n n5 2 2 Classifying Functions Functions Exp Constant Polynomial Double Exp Exponential Logarithmic Poly Logarithmic 5 5 log n (log n)5 n5 25n

16. Classifying Functions? Polynomial

17. Classifying Functions Polynomial ? Cubic Quadratic Linear 5n4 5n3 5n 5n2

18. Logarithmic • log10n = # digits to write n • log2n = # bits to write n = 3.32 log10n • log(n1000) = 1000 log(n) Differ only by a multiplicative constant.

19. Poly Logarithmic (log n)5 = log5 n

20. Logarithmic << Polynomial For sufficiently large n log1000 n << n0.001

21. Linear << Quadratic For sufficiently large n 10000 n << 0.0001 n2

22. Polynomial << Exponential For sufficiently large n n1000 << 20.001 n

23. 25n n5 2 2 Ordering Functions Functions Exp Constant Polynomial << << << << << << Double Exp Exponential Logarithmic Poly Logarithmic 5 5 log n (log n)5 n5 25n << << << << << <<

24. Yes Yes Yes Yes Yes No Which Functions are Constant? • 5 • 1,000,000,000,000 • 0.0000000000001 • -5 • 0 • 8 + sin(n)

25. 9 Lie in between 7 Yes Which Functions are “Constant”? The running time of the algorithm is a “Constant” It does not depend significantly on the size of the input. Yes • 5 • 1,000,000,000,000 • 0.0000000000001 • -5 • 0 • 8 + sin(n) Yes Yes No No

26. Which Functions are Quadratic? • n2 • … ?

27. Which Functions are Quadratic? • n2 • 0.001 n2 • 1000 n2 Some constant times n2.

28. Which Functions are Quadratic? • n2 • 0.001 n2 • 1000 n2 • 5n2 + 3n + 2log n

29. Which Functions are Quadratic? • n2 • 0.001 n2 • 1000 n2 • 5n2 + 3n + 2log n Lie in between

30. Which Functions are Quadratic? • n2 • 0.001 n2 • 1000 n2 • 5n2 + 3n + 2log n Ignore low-order terms Ignore multiplicative constants. Ignore "small" values of n. Write θ(n2).

31. Which Functions are Polynomial? • n5 • … ?

32. Which Functions are Polynomial? • nc • n0.0001 • n10000 n to some constant power.

33. Which Functions are Polynomial? • nc • n0.0001 • n10000 • 5n2 + 8n + 2log n • 5n2 log n • 5n2.5

34. Which Functions are Polynomial? • nc • n0.0001 • n10000 • 5n2 + 8n + 2log n • 5n2 log n • 5n2.5 Lie in between

35. Which Functions are Polynomials? • nc • n0.0001 • n10000 • 5n2 + 8n + 2log n • 5n2 log n • 5n2.5 Ignore low-order terms Ignore power constant. Ignore "small" values of n. Write nθ(1)

36. Which Functions are Exponential? • 2n • … ?

37. Which Functions are Exponential? • 2n • 20.0001 n • 210000 n n times some constant power raises to the power of 2.

38. Which Functions are Exponential? • 2n • 20.0001 n • 210000 n • 8n • 2n / n100 • 2n· n100 too small? too big?

39. Which Functions are Exponential? • 2n • 20.0001 n • 210000 n • 8n • 2n / n100 • 2n· n100 Lie in between = 23n > 20.5n < 22n

40. Which Functions are Exponential? • 2n • 20.0001 n • 210000 n • 8n • 2n / n100 • 2n· n100 = 23n > 20.5n < 22n 20.5n > n100 2n = 20.5n· 20.5n > n100· 20.5n 2n / n100 > n0.5n

41. Which Functions are Exponential? • 2n • 20.0001 n • 210000 n • 8n • 2n / n100 • 2n· n100 Ignore low-order terms Ignore base. Ignore "small" values of n. Ignore polynomial factors. Write 2θ(n)

42. 2θ(n) nθ(1) 2 2 Classifying Functions Functions Exp Constant Polynomial Double Exp Exponential Logarithmic Poly Logarithmic θ(1) θ(log n) (log n)θ(1) nθ(1) 2θ(n)

43. Notations

44. Definition of Theta f(n) = θ(g(n))

45. Definition of Theta f(n) = θ(g(n)) f(n) is sandwiched between c1g(n)and c2g(n)

46. Definition of Theta f(n) = θ(g(n)) f(n) is sandwiched between c1g(n)and c2g(n) for some sufficiently small c1 (= 0.0001) for some sufficiently large c2 (= 1000)

47. Definition of Theta f(n) = θ(g(n)) For all sufficiently large n

48. Definition of Theta f(n) = θ(g(n)) For all sufficiently large n For some definition of “sufficiently large”

49. Definition of Theta 3n2 + 7n + 8 = θ(n2)