Knowledge Reserve--Basic Algorithms-Sorting Algorithms

1. Knowledge - time complexity and space complexity

1.2 Time complexity

The time an algorithm takes is proportional to the number of executions of its statements. The number of executions of basic operations in the algorithm is the time complexity of the algorithm.

1.3 Space complexity

Space complexity is not how many bytes of space the program occupies. Space complexity is the number of variables.

1.3 Big O asymptotic notation

  • Big O notation: is a mathematical notation used to describe the asymptotic behavior of a function. Derive the Big O method:
  • 1. Replace all additive constants in the run time with constant 1.
  • 2. In the modified running times function, only the highest order term is retained.
  • 3. If the highest-order term exists and is not 1, remove the constant multiplied by this term. The result is Big O order.

2. Sorting algorithm

Recommend a blog’s top ten classic sorting algorithms (animated picture demonstration) - One Pixel - Blog Garden (cnblogs.com)

For the knowledge related to recursion encountered, you can read this blog on how to quickly understand recursion - just read this_The recursive body of the recursive function_The blog where I came to Laotie to do this bowl of code-CSDN blog

The main thing about recursion is to find its boundary conditions, and then look at the recursion body to understand what each recursion is doing. 

There are two functions often encountered in sorting, one is push() and the other is shift().

The push() method adds one or more elements to the end of the array and returns the new length of the array. It modifies and replaces the original array rather than generating a new modified version of the array.

shift() removes the first element from the array and returns the value of that element. This method changes the length of the array.

Guess you like

Origin blog.csdn.net/Orange_sparkle/article/details/132384044