当前位置:网站首页>时间复杂度和空间复杂度
时间复杂度和空间复杂度
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 所占存储空间的函数
边栏推荐
猜你喜欢
TCP/IP四层模型
Getting Started Documentation 12 webserve + Hot Updates
交换机原理
【Day5】软硬链接 文件存储,删除,目录管理命令
Unity中的GetEnumerator 方法及MoveNext、Reset方法
URP渲染管线实战教程系列 之URP渲染管线实战解密(一)
Remembering my first CCF-A conference paper | After six rejections, my paper is finally accepted, yay!
【Day8】(超详细步骤)使用LVM扩容
【Day1】(超详细步骤)构建软RAID磁盘阵列
spark source code - task submission process - 1-sparkSubmit
随机推荐
D39_欧拉角与四元数
入门文档05 使用cb()指示当前任务已完成
Getting Started 04 When a task depends on another task, it needs to be executed in sequence
VRRP原理及命令
Getting Started Document 09 Standalone watch
Contextual non-local alignment of full-scale representations
VLAN详解及实验
VLAN details and experiments
Getting Started Doc 06 Adding files to a stream
乘云科技受邀出席2022阿里云合作伙伴大会荣获“聚力行远奖”
[Day5] Soft and hard links File storage, deletion, directory management commands
【机器学习】1单变量线性回归
D41_缓冲池
I217-V network disconnection problem in large traffic under openwrt soft routing
D46_给刚体施加的力
Why can't I add a new hard disk to scan?How to solve?
Getting Started 03 Distinguish between development and production environments ("hot update" is performed only in the production environment)
无影云桌面
Unity huatuo 革命性热更系列1.2 huatuo热更环境安装与示例项目
静态路由