Data structure and algorithm time and space complexity

Algorithm complexity analysis
Big O symbol is called asymptotic upper bound method in mathematics.
2n n = 2n square########n+n n = n+n square
When n is very large. The value of n square will become dominant, we can ignore
the time complexity of n commonly used

  • 1: One-time assignment at constant time
  • 2 log n: logarithmic time binary search
  • n: linear search in linear time
  • nlong n: logarithmic linear time quick sort
  • n square: square double cycle
  • n cubic: cubic triple cycle
  • 2 to the nth power: exponential recursive spherical Fibonacci sequence
  • n! : Order
    space complexity

Time for space, space for time
Space for time: Typically, they are collections in python. Although they are wasteful of space, O(1) can be used to find
time for space through subscripts : when our space is not enough, the typical is Space invalidation algorithm, it is impossible for us to cache the same capacity of data, we will use some space cache elimination algorithms to ensure that the space is available

Guess you like

Origin blog.csdn.net/weixin_44865158/article/details/100777443