hello-algo/codes/javascript/chapter_computational_complexity/time_complexity.js
2023-01-02 18:47:36 +08:00

22 lines
401 B
JavaScript

/**
* 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);
}
}