当前位置:网站首页>时间复杂度和空间复杂度
时间复杂度和空间复杂度
2022-08-05 05:19:00 【CrazyQiQi】
时间复杂度和空间复杂度
1. 算法的时间复杂度
概念:进行算法分析时,语句总的执行次数 T(n) 关于问题规模 n 的函数,进而分析 T(n) 随 n 的变化并确定 T(n) 的数量级。
公式:T(n)=O(f(n)),f(n) 是问题规模 n 的某个函数
常见的时间复杂度
| 例子 | 时间复杂度 | 术语 |
|---|---|---|
| 5201314 | O(1) | 常数阶 |
| 3n+4 | O(n) | 线性阶 |
| 3n^2+4 | O(n^2) | 平方阶 |
| 3log(2)n+4 | O(logn) | 对数阶 |
| 2n+3nlog(2)n+4 | O(nlogn) | nlogn阶 |
| n3+2n2+4n+3 | O(n^3) | 立方阶 |
| 2^n | O(2^n) | 指数阶 |
常用时间复杂度所耗费的时间
2. 算法的空间复杂度
概念:算法的空间复杂度通过计算算法所需的存储空间实现
计算公式:S(n) = O(f(n)),其中,n 为问题规模,f(n) 为语句关于 n 所占存储空间的函数
边栏推荐
- 入门文档11 自动添加版本号
- spark源码-任务提交流程之-2-YarnClusterApplication
- The spark operator - repartition operator
- 【Day8】Knowledge about disk and disk partition
- 不吹不黑,这的确是我看过微服务架构最好的文章!
- Servlet跳转到JSP页面,转发和重定向
- dsf5.0 弹框点确定没有返回值的问题
- spark算子-wholeTextFiles算子
- I217-V network disconnection problem in large traffic under openwrt soft routing
- spark operator-wholeTextFiles operator
猜你喜欢
随机推荐
TCP/IP四层模型
Spark源码-任务提交流程之-6.2-sparkContext初始化-TaskScheduler任务调度器
腾讯云云函数SCF—入门须知
交换机原理
【Day8】磁盘及磁盘的分区有关知识
来来来,一文让你读懂Cocos Creator如何读写JSON文件
小度 小度 在呢!
Image compression failure problem
[Day6] File system permission management, file special permissions, hidden attributes
成功的独立开发者应对失败&冒名顶替综
游戏引擎除了开发游戏还能做什么?
Unity3D中的ref、out、Params三种参数的使用
如何用UE5渲染一个可爱的茶壶屋?
入门文档12 webserve + 热更新
The problem of redirecting to the home page when visiting a new page in dsf5.0
Getting Started 03 Distinguish between development and production environments ("hot update" is performed only in the production environment)
虚幻引擎5都有哪些重要新功能?
通过单总线调用ds18b20的问题
如何使用Houdini进行程序化优化?
js动态获取屏幕宽高度









