forked from hunterhug/goa.c
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
28 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,21 @@ | ||
# 复杂度及渐进符号 | ||
|
||
## 一、算法复杂度 | ||
|
||
首先每个程序运行过程中,都要占用一定的计算机资源,比如内存,磁盘等,这些是空间,计算过程中需要判断,循环执行某些逻辑,周而反复,这些是时间。 | ||
|
||
那么一个算法有多好,多快,怎么衡量一个算法的好坏? | ||
|
||
所以,计算机科学在算法分析过程中,提出了算法复杂度理论,这套理论可以量化算法的效率,以此作为标准,方便我们能衡量到底选择哪一种算法。 | ||
|
||
复杂度有两个维度:时间和空间。 | ||
|
||
我们说,一个实现了某算法的程序,如果计算的速度越快,那么这个算法时间复杂度越低,如果占用的资源空间越大,那么空间复杂度越高。复杂度越高,代表效率越低,就越不是一个好的算法。 | ||
|
||
我们要选择复杂度低的算法,衡量好空间和时间的消耗,选出适合特定场景的算法。 | ||
|
||
这两个复杂度维度的量化过程都是一样的,所以我们这里主要介绍时间复杂度。 | ||
|
||
## 二、渐进符号 | ||
|
||
如何量化一个复杂度,到底有多复杂,计算机科学抽象出了几个时间复杂度渐进符号。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters