编程语言/时间复杂度:修订间差异
来自康健生活
| 第2行: | 第2行: | ||
渐进时间复杂度(asymptotic time complexity),表示代码执行时间随着数据增长的变化趋势。记为 <code>O(n)</code>。n 代表输入数据的量。 | 渐进时间复杂度(asymptotic time complexity),表示代码执行时间随着数据增长的变化趋势。记为 <code>O(n)</code>。n 代表输入数据的量。 | ||
== 常规复杂度 == | == 常规复杂度 == | ||
常规复杂度一般有四种:<math>O(1)</math>、<math>O(n)</math>、<math>O(\log_{2} n)</math>、<math>O(n\log_{2} n)</math>、<math>O(n^2)</math> | |||
* | * <math>O(n)</math>:数据量与耗时同步增大,eq:遍历 | ||
* | * <math>O(n^2)</math>:eq:冒泡排序。 | ||
* | * <math>O(\log_{2} n)</math>:eq:二分查找。 | ||
* | * <math>O(n\log_{2} n)</math>:eq:归并排序。 | ||
* | * <math>O(1)</math>:eq: 哈希算法。 | ||
== 标题文字 == | == 标题文字 == | ||