Reading Notes: Introduction to Algorithms in Chapter 1 of "Algorithm Diagrams"

Binary search #

Binary search is half search, and it is effective when the queue list is ordered.

For a list of n elements, binary search requires at mostlOg2nlog2n steps, a simple sequential search requires at most n steps.

log #

Logarithm: The logarithmic operation is the inverse of the exponentiation operation

N=ax(a>0,a1)N=ax(a>0,a≠1)xxthat isaabaseNNlogarithm, denoted asx=logaNx=loga⁡N,in:

  • aa : end
  • NN : Antilogarithm
  • xx : byaabaseNNlogarithm of

power:

log refers to both log2log2

log8log⁡8 = log28log2⁡8 = 3 (23=823=8)

  1. The logarithm to the base 10 is called the common logarithm, denoted aslglg
  2. with irrational numbersee(e=2.71828e=2.71828…) base logarithm is called natural logarithm, denoted aslnln
  3. Zero has no logarithm
  4. In the range of real numbers, negative numbers have no logarithm; in the range of complex numbers, negative numbers have logarithms

Time Complexity #

Practical complexity of simple sequential search O(n)O(n)

time complexity of binary search O(logn)O(log⁡n)

Time complexity represents the worst-case running time

Common time complexity #

  • O(logn)O(log⁡n) logarithmic time
  • O(n)O(n) linear time
  • O(n×logn)O(n×log⁡n)
  • O(n2)O(n2)
  • O(n!)O(n!) factorial of n

Original post address

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326353825&siteId=291194637