mirror of
https://github.com/krahets/hello-algo.git
synced 2024-12-27 12:26:28 +08:00
27 lines
454 B
Go
27 lines
454 B
Go
|
// File: space_complexity_test.go
|
||
|
// Created Time: 2022-12-15
|
||
|
// Author: cathay (cathaycchen@gmail.com)
|
||
|
|
||
|
package chapter_computational_complexity
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
. "github.com/krahets/hello-algo/pkg"
|
||
|
)
|
||
|
|
||
|
func TestSpaceComplexity(t *testing.T) {
|
||
|
n := 5
|
||
|
// 常數階
|
||
|
spaceConstant(n)
|
||
|
// 線性階
|
||
|
spaceLinear(n)
|
||
|
spaceLinearRecur(n)
|
||
|
// 平方階
|
||
|
spaceQuadratic(n)
|
||
|
spaceQuadraticRecur(n)
|
||
|
// 指數階
|
||
|
root := buildTree(n)
|
||
|
PrintTree(root)
|
||
|
}
|