Day19 Analysis of Algorithms(Ⅰ)

●There may exist various algorithms for the same problem.
●We then compare these algorithms by measuring their efficiency.
●To do so, we estimate the growth rate of running time in function of input size n.
●We proceed to introduce the notion of time complexity.
●Similar to time complexity(时间复杂度), we later turn to the notion of space complexity(空间复杂度).
EX:Sum
https://ithelp.ithome.com.tw/upload/images/20211001/201404570bOha8yZcm.jpg
第一行时间加总是2
第二行时间加总是n+1
第三行时间加总是2n
第四行时间加总是n
总共是4n+3
Big-O Notation
Big-o定义: f (n) ∈ O(g(n)) as n →∞
若有一个常数 c > 0 还有一些n0,那麽 f (n) ≤ c ×g(n) ∀n ≥ n0.
快速判断时间复杂度的方法:
1.Keep the leading term only.留着首项
2.Drop the coefficient.首项常数拿掉
3. time complexity.即为时间复杂度
EX:1. 8n^2 −3n + 4. ∈ O(n^2) 2.4n+3∈ O(n)
有一个k层回圈的规则,当有一个k层回圈则时间复杂度为O(n^k)。


<<:  Day16 - Shioaji X Backtesting - 参数最佳化

>>:  CSS微动画 - Loading又来了!文字版再出击~

[第二十一只羊] 迷雾森林舞会XV 建立村庄 游戏角色设定

天亮了 昨晚是平安夜 关於迷雾森林故事 习惯 洛神:8号玩家请继续发言 8号: 我的视角,我觉得我的...

Day1 写程序的前置工作!

安装环境第一步骤 App Store 搜寻Xcode并下载 下载後并创立一个专案 进入後系统帮我们预...

课堂笔记 - 深度学习 Deep Learning (11)

Gradient Descent – one weight with Bias 上篇的说明当 b=...

Day 49 (Node.js)

1.express-session设定 var express = require('express...

JavaScript学习日记 : Day23 - 解构赋值

解构赋值(Destructuring Assignment)是一个在ES6的新特性,用於提取阵列或物...