[Data Structure] Introduction Summary

Focus on summarizing the time complexity:

1. Concept

The frequency of a sentence refers to the repeated execution of the sentence in the algorithm frequency. The sum of the frequency of all sentences in the algorithm is recorded as T(n), which is a function of the problem scale n of the algorithm, and the time complexity mainly analyzes the order of magnitude of T(n). The frequency f(n) of the basic operations in the algorithm is usually used to analyze the time complexity of the algorithm. The time complexity of the algorithm is recorded as:

T(n)=O(f(n))

O represents the order of magnitude of T(n). It means that as the problem size n increases, the growth rate of the algorithm execution time is the same as the growth rate of f(n), which is called the progressive time complexity of the algorithm, or time complexity for short. Where f(n) is a certain function of the problem size n. In this way, O() is used to reflect the notation of algorithm time complexity, which we call Big O notation.

2. Calculation method

1) Replace all addition constants in the running time with a constant 1.

2) In the modified running count function, only the highest order items are retained.

3) If the highest-order term exists and is not 1, remove the constant multiplied by this term.

The result obtained is a big O order.

Note:

1) To analyze the complexity of the algorithm, the key is to analyze the operation of the loop structure.

2) Time spent in common time complexity:

O(1)

3) Generally, the time complexity we mentioned is the worst time complexity

Leave a Comment

Your email address will not be published.