mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-07 15:01:58 +08:00
code: added code for time complexity chapter
This commit is contained in:
@ -0,0 +1,21 @@
|
||||
/**
|
||||
* File: time_complexity.js
|
||||
* Created Time: 2023-01-02
|
||||
* Author: RiverTwilight (contact@rene.wang)
|
||||
*/
|
||||
|
||||
function algorithm_A(n) {
|
||||
console.log(0);
|
||||
}
|
||||
// 算法 B 时间复杂度:线性阶
|
||||
function algorithm_B(n) {
|
||||
for (var i = 0; i < n; i++) {
|
||||
console.log(0);
|
||||
}
|
||||
}
|
||||
// 算法 C 时间复杂度:常数阶
|
||||
function algorithm_C(n) {
|
||||
for (var i = 0; i < 1000000; i++) {
|
||||
console.log(0);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user