23 lines
1.6 KiB
Markdown
23 lines
1.6 KiB
Markdown
---
|
|
title: BigO(大O表示法)
|
|
date: 2021-07-09 22:08:57
|
|
updated: 2021-10-05 13:52:00
|
|
tags:
|
|
- 算法
|
|
- 大O
|
|
abbrlink: 64501
|
|
categories: 算法
|
|
mathjax: true
|
|
---
|
|
# 什么是大O表示法?
|
|
大O表示法是一种特殊的表示法,指出了算法的速度有多块。实际上,我们通常要使用别人编写的算法,在这种情况下,知道这些算法的数独大有裨益。
|
|
|
|
# 常见的大O运行时间
|
|
以下的运行时间,按照从快到慢的序列列出了经常遇到的5种大O运行时间
|
|
- <math xmlns='http://www.w3.org/1998/Math/MathML'><mi>O</mi><mrow><mo>(</mo><mi>log</mi><mi>n</mi><mo>)</mo></mrow></math> - 对数时间,这样的算法包括二分查找。
|
|
- <math xmlns='http://www.w3.org/1998/Math/MathML'><mi>O</mi> <mrow><mo>(</mo><mi>n</mi><mo>)</mo></mrow></math> - 线性时间,这样的算法包括简单查找。
|
|
- <math xmlns='http://www.w3.org/1998/Math/MathML'><mi>O</mi><mrow><mo>(</mo><mi>n</mi><mi>log</mi><mi>n</mi><mo>)</mo></mrow></math> - 这样的算法包括快速排序——一种数独较快的排序算法。
|
|
- <math xmlns='http://www.w3.org/1998/Math/MathML'><mi>O</mi><mrow><mo>(</mo><msup><mrow><mi>n</mi></mrow><mrow><mn>2</mn></mrow></msup><mo>)</mo></mrow></math> - 这样的算法包括选择排序——一种速度较慢的排序算法。
|
|
- <math xmlns='http://www.w3.org/1998/Math/MathML'><mi>O</mi><mrow><mo>(</mo><mi>n</mi><mo>!</mo><mo>)</mo></mrow></math> - 这种算法包括一些旅行商问题的解决方案——一种非常慢的算法。
|
|
|
|
还有很多的一些大O的运行时间,如果大家知道的话,可以写在评论区那里。 |