Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Calculate the time complexity of the algorithm

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report