Get the App
SLTechnology News&Howtos  ›  Servers  › 

Calculate the time complexity of the algorithm

Shulou Source: shulou.com Published: 2022-06-02 17:14:32 10月15日 Update

1. Comparison of time complexity of common algorithms:

The time complexity of common algorithms from small to large is as follows:

Please (1) < logn < nlogn (n) < listen (N2) < listen (n3) <... < broadcast (2) < broadcast (n!)

Repeat (1) indicates that the number of times the basic statement is executed is a constant. Generally speaking, as long as there is no circular statement in the algorithm, its time complexity is equal (1). Logn, nlogn, N2 and N2 are called polynomial time, while cubic (2) and cubic (n!) It's called exponential time. Computer scientists generally believe that the former is an effective algorithm, and this kind of problem is called P-type problem, while the latter is called NP problem.

This can only be a basic computational time complexity, and the specific operation will be related to the hardware.

2. Problems related to computing time complexity.

I. single multiple choice questions

1. An algorithm should be ().

a. Program B. The description of the step of solving the problem C. To meet the five basic characteristics D. an and C.

1. B

Programs do not necessarily satisfy finiteness, such as endless loops, operating systems, etc., while algorithms must be finite. The algorithm represents the description of the steps of solving the problem, and the program is the specific implementation of the algorithm on the computer.

two。 The time complexity of an algorithm is O (N2), which indicates the () of the algorithm.

a. The scale of the problem is N2 B. The execution time is equal to N2

c. The execution time is proportional to N2. The scale of the problem is proportional to N2.

2. C

The time complexity is O (N2), which indicates the execution time T (n) of the algorithm.

Tags: Time algorithm complexity problem B.Personality C. D.C. Program statement A. scale Integer constant Common degree proportional step computer factorial Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Shulou Tech Info Docker OPPO Reno Shulou Information