Files
Yudong Jin 2778a6f9c7 Translate all code to English (#1836)
* Review the EN heading format.

* Fix pythontutor headings.

* Fix pythontutor headings.

* bug fixes

* Fix headings in **/summary.md

* Revisit the CN-to-EN translation for Python code using Claude-4.5

* Revisit the CN-to-EN translation for Java code using Claude-4.5

* Revisit the CN-to-EN translation for Cpp code using Claude-4.5.

* Fix the dictionary.

* Fix cpp code translation for the multipart strings.

* Translate Go code to English.

* Update workflows to test EN code.

* Add EN translation for C.

* Add EN translation for CSharp.

* Add EN translation for Swift.

* Trigger the CI check.

* Revert.

* Update en/hash_map.md

* Add the EN version of Dart code.

* Add the EN version of Kotlin code.

* Add missing code files.

* Add the EN version of JavaScript code.

* Add the EN version of TypeScript code.

* Fix the workflows.

* Add the EN version of Ruby code.

* Add the EN version of Rust code.

* Update the CI check for the English version  code.

* Update Python CI check.

* Fix cmakelists for en/C code.

* Fix Ruby comments
2025-12-31 07:44:52 +08:00

49 lines
1.5 KiB
Go

// File: time_complexity_test.go
// Created Time: 2022-12-13
// Author: msk397 (machangxinq@gmail.com)
package chapter_computational_complexity
import (
"fmt"
"testing"
)
func TestTimeComplexity(t *testing.T) {
n := 8
fmt.Println("Input data size n =", n)
count := constant(n)
fmt.Println("Number of constant-order operations =", count)
count = linear(n)
fmt.Println("Number of linear-order operations =", count)
count = arrayTraversal(make([]int, n))
fmt.Println("Number of linear-order (array traversal) operations =", count)
count = quadratic(n)
fmt.Println("Number of quadratic-order operations =", count)
nums := make([]int, n)
for i := 0; i < n; i++ {
nums[i] = n - i
}
count = bubbleSort(nums)
fmt.Println("Number of quadratic-order (bubble sort) operations =", count)
count = exponential(n)
fmt.Println("Number of exponential-order (loop implementation) operations =", count)
count = expRecur(n)
fmt.Println("Number of exponential-order (recursive implementation) operations =", count)
count = logarithmic(n)
fmt.Println("Number of logarithmic-order (loop implementation) operations =", count)
count = logRecur(n)
fmt.Println("Number of logarithmic-order (recursive implementation) operations =", count)
count = linearLogRecur(n)
fmt.Println("Number of linearithmic-order (recursive implementation) operations =", count)
count = factorialRecur(n)
fmt.Println("Number of factorial-order (recursive implementation) operations =", count)
}