feat(space_complexity): add the Go code to space complexity docs (Chapter of Computational Complexity)

This commit is contained in:
Cathay
2022-12-15 16:41:47 +08:00
parent b3d642fa85
commit 5617f8246f
3 changed files with 283 additions and 7 deletions

View File

@@ -0,0 +1,30 @@
// File: space_complexity_test.go
// Created Time: 2022-12-15
// Author: cathay (cathaycchen@gmail.com)
package chapter_computational_complexity
import (
"testing"
)
func TestSpaceComplexity(t *testing.T) {
/* ======= Test Case ======= */
n := 5
/* ====== Driver Code ====== */
// 常数阶
spaceConstant(n)
// 线性阶
spaceLinear(n)
spaceLinearRecur(n)
// 平方阶
spaceQuadratic(n)
spaceQuadraticRecur(n)
// 指数阶
root := buildTree(n)
printTree(root)
}