mirror of
https://github.com/krahets/hello-algo.git
synced 2025-01-26 16:48:41 +08:00
22 lines
401 B
JavaScript
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);
|
|
}
|
|
}
|