I showed you my source code, pls respond
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
2.8 KiB

4 years ago
  1. #+TITLE: Efficiency of Algorithms
  2. #+AUTHOR: Christopher James Hayward
  3. #+HUGO_BASE_DIR: ~/.local/source/website
  4. #+HUGO_SECTION: notes
  5. + Algorithms must be analyzed to determine resource usage
  6. + Efficiency is analogous to engineering productivity for a repeating process
  7. + Measured in complexity of time and space (resources)
  8. * Background
  9. Importance of efficiency with respect to time was first emphasized by *Ada Lovelace* in 1843 regarding the babbage machine:
  10. #+begin_quote
  11. In almost every computation a great variety of arrangements for the succession of the process is possible, and variouis considerations must influence the selections amongst them for the purpose of a calculating engine. One essential object is to chose that arrangement which shall tend to reduce to a minimum the time necessary for completing the calculation.
  12. #+end_quote
  13. * Analysis
  14. The most commonly used notation to describe resource consumption (complexity) is using *Donald Knuth's* =Big O= notation.
  15. | Notation | Name | Example |
  16. |--------------+--------------+----------------------------------------------------------------|
  17. | O(1) | Constant | Finding the median in a sorted list of measurements |
  18. | O(log n) | Logarithmic | Finding an item in an sorted array with a binary search |
  19. | O(n) | Linear | Finding an item in an unsorted array |
  20. | O(n log n) | Linearithmic | Performing a fast sorting algorithm |
  21. | O(n²) | Quadratic | Multiplying two n digit numbers by a simple algorithm |
  22. | O(n²), c > 1 | Exponential | Finding the optimal solution to the traveling salesman problem |
  23. * Measurement
  24. Expression as a function of the size of the input ~n~, with the main measurements being:
  25. + Time :: How long does the algorithm take to complete?
  26. + Space :: How much working memory is required?
  27. Other measurements for devices whose power needs to be factored in, such as for battery operated devices or super computers:
  28. + Direct power :: How much power is needed to compute the algorithm?
  29. + Indirect power :: How much power is needed for cooling, lighting, etc?
  30. Less commonly used:
  31. + Transmission size :: How much data must be transferred for operation?
  32. + External space :: Space needed physically (such as on disk)
  33. + Response time :: Relevant in real time applications
  34. + Total cost :: Cost of hardware dedication
  35. ** Time
  36. + Uses time complexity analysis
  37. + Measured in CPU time usage
  38. + Detailed estimates needed to compare performance
  39. + Difficult to measure in parallel processing
  40. ** Space
  41. Concerned with the usage of memory resources, typically the memory or storage needed to hold:
  42. + Code for the algorithm
  43. + Working space
  44. + Input data
  45. + Output data
  46. + Processing data