feat: Traditional Chinese version (#1163)

* First commit

* Update mkdocs.yml

* Translate all the docs to traditional Chinese

* Translate the code files.

* Translate the docker file

* Fix mkdocs.yml

* Translate all the figures from SC to TC

* 二叉搜尋樹 -> 二元搜尋樹

* Update terminology.

* Update terminology

* 构造函数/构造方法 -> 建構子
异或 -> 互斥或

* 擴充套件 -> 擴展

* constant - 常量 - 常數

* 類	-> 類別

* AVL -> AVL 樹

* 數組 -> 陣列

* 係統 -> 系統
斐波那契數列 -> 費波那契數列
運算元量 -> 運算量
引數 -> 參數

* 聯絡 -> 關聯

* 麵試 -> 面試

* 面向物件 -> 物件導向
歸併排序 -> 合併排序
范式 -> 範式

* Fix 算法 -> 演算法

* 錶示 -> 表示
反碼 -> 一補數
補碼 -> 二補數
列列尾部 -> 佇列尾部
區域性性 -> 區域性
一摞 -> 一疊

* Synchronize with main branch

* 賬號 -> 帳號
推匯 -> 推導

* Sync with main branch

* First commit

* Update mkdocs.yml

* Translate all the docs to traditional Chinese

* Translate the code files.

* Translate the docker file

* Fix mkdocs.yml

* Translate all the figures from SC to TC

* 二叉搜尋樹 -> 二元搜尋樹

* Update terminology

* 构造函数/构造方法 -> 建構子
异或 -> 互斥或

* 擴充套件 -> 擴展

* constant - 常量 - 常數

* 類	-> 類別

* AVL -> AVL 樹

* 數組 -> 陣列

* 係統 -> 系統
斐波那契數列 -> 費波那契數列
運算元量 -> 運算量
引數 -> 參數

* 聯絡 -> 關聯

* 麵試 -> 面試

* 面向物件 -> 物件導向
歸併排序 -> 合併排序
范式 -> 範式

* Fix 算法 -> 演算法

* 錶示 -> 表示
反碼 -> 一補數
補碼 -> 二補數
列列尾部 -> 佇列尾部
區域性性 -> 區域性
一摞 -> 一疊

* Synchronize with main branch

* 賬號 -> 帳號
推匯 -> 推導

* Sync with main branch

* Update terminology.md

* 操作数量(num. of operations)-> 操作數量

* 字首和->前綴和

* Update figures

* 歸 -> 迴
記憶體洩漏 -> 記憶體流失

* Fix the bug of the file filter

* 支援 -> 支持
Add zh-Hant/README.md

* Add the zh-Hant chapter covers.
Bug fixes.

* 外掛 -> 擴充功能

* Add the landing page for zh-Hant version

* Unify the font of the chapter covers for the zh, en, and zh-Hant version

* Move zh-Hant/ to zh-hant/

* Translate terminology.md to traditional Chinese
This commit is contained in:
Yudong Jin
2024-04-06 02:30:11 +08:00
committed by GitHub
parent 33d7f8a2e5
commit 5f7385c8a3
1875 changed files with 102923 additions and 18 deletions
@@ -0,0 +1,107 @@
/**
* File: array.swift
* Created Time: 2023-01-05
* Author: nuomi1 (nuomi1@qq.com)
*/
/* */
func randomAccess(nums: [Int]) -> Int {
// [0, nums.count)
let randomIndex = nums.indices.randomElement()!
//
let randomNum = nums[randomIndex]
return randomNum
}
/* */
func extend(nums: [Int], enlarge: Int) -> [Int] {
//
var res = Array(repeating: 0, count: nums.count + enlarge)
//
for i in nums.indices {
res[i] = nums[i]
}
//
return res
}
/* index num */
func insert(nums: inout [Int], num: Int, index: Int) {
// index
for i in nums.indices.dropFirst(index).reversed() {
nums[i] = nums[i - 1]
}
// num index
nums[index] = num
}
/* index */
func remove(nums: inout [Int], index: Int) {
// index
for i in nums.indices.dropFirst(index).dropLast() {
nums[i] = nums[i + 1]
}
}
/* */
func traverse(nums: [Int]) {
var count = 0
//
for i in nums.indices {
count += nums[i]
}
//
for num in nums {
count += num
}
//
for (i, num) in nums.enumerated() {
count += nums[i]
count += num
}
}
/* */
func find(nums: [Int], target: Int) -> Int {
for i in nums.indices {
if nums[i] == target {
return i
}
}
return -1
}
@main
enum _Array {
/* Driver Code */
static func main() {
/* */
let arr = Array(repeating: 0, count: 5)
print("陣列 arr = \(arr)")
var nums = [1, 3, 2, 5, 4]
print("陣列 nums = \(nums)")
/* */
let randomNum = randomAccess(nums: nums)
print("在 nums 中獲取隨機元素 \(randomNum)")
/* */
nums = extend(nums: nums, enlarge: 3)
print("將陣列長度擴展至 8 ,得到 nums = \(nums)")
/* */
insert(nums: &nums, num: 6, index: 3)
print("在索引 3 處插入數字 6 ,得到 nums = \(nums)")
/* */
remove(nums: &nums, index: 2)
print("刪除索引 2 處的元素,得到 nums = \(nums)")
/* */
traverse(nums: nums)
/* */
let index = find(nums: nums, target: 3)
print("在 nums 中查詢元素 3 ,得到索引 = \(index)")
}
}
@@ -0,0 +1,90 @@
/**
* File: linked_list.swift
* Created Time: 2023-01-08
* Author: nuomi1 (nuomi1@qq.com)
*/
import utils
/* n0 P */
func insert(n0: ListNode, P: ListNode) {
let n1 = n0.next
P.next = n1
n0.next = P
}
/* n0 */
func remove(n0: ListNode) {
if n0.next == nil {
return
}
// n0 -> P -> n1
let P = n0.next
let n1 = P?.next
n0.next = n1
}
/* index */
func access(head: ListNode, index: Int) -> ListNode? {
var head: ListNode? = head
for _ in 0 ..< index {
if head == nil {
return nil
}
head = head?.next
}
return head
}
/* target */
func find(head: ListNode, target: Int) -> Int {
var head: ListNode? = head
var index = 0
while head != nil {
if head?.val == target {
return index
}
head = head?.next
index += 1
}
return -1
}
@main
enum LinkedList {
/* Driver Code */
static func main() {
/* */
//
let n0 = ListNode(x: 1)
let n1 = ListNode(x: 3)
let n2 = ListNode(x: 2)
let n3 = ListNode(x: 5)
let n4 = ListNode(x: 4)
//
n0.next = n1
n1.next = n2
n2.next = n3
n3.next = n4
print("初始化的鏈結串列為")
PrintUtil.printLinkedList(head: n0)
/* */
insert(n0: n0, P: ListNode(x: 0))
print("插入節點後的鏈結串列為")
PrintUtil.printLinkedList(head: n0)
/* */
remove(n0: n0)
print("刪除節點後的鏈結串列為")
PrintUtil.printLinkedList(head: n0)
/* */
let node = access(head: n0, index: 3)
print("鏈結串列中索引 3 處的節點的值 = \(node!.val)")
/* */
let index = find(head: n0, target: 2)
print("鏈結串列中值為 2 的節點的索引 = \(index)")
}
}
@@ -0,0 +1,63 @@
/**
* File: list.swift
* Created Time: 2023-01-08
* Author: nuomi1 (nuomi1@qq.com)
*/
@main
enum List {
/* Driver Code */
static func main() {
/* */
var nums = [1, 3, 2, 5, 4]
print("串列 nums = \(nums)")
/* */
let num = nums[1]
print("訪問索引 1 處的元素,得到 num = \(num)")
/* */
nums[1] = 0
print("將索引 1 處的元素更新為 0 ,得到 nums = \(nums)")
/* */
nums.removeAll()
print("清空串列後 nums = \(nums)")
/* */
nums.append(1)
nums.append(3)
nums.append(2)
nums.append(5)
nums.append(4)
print("新增元素後 nums = \(nums)")
/* */
nums.insert(6, at: 3)
print("在索引 3 處插入數字 6 ,得到 nums = \(nums)")
/* */
nums.remove(at: 3)
print("刪除索引 3 處的元素,得到 nums = \(nums)")
/* */
var count = 0
for i in nums.indices {
count += nums[i]
}
/* */
count = 0
for x in nums {
count += x
}
/* */
let nums1 = [6, 8, 7, 10, 9]
nums.append(contentsOf: nums1)
print("將串列 nums1 拼接到 nums 之後,得到 nums = \(nums)")
/* */
nums.sort()
print("排序串列後 nums = \(nums)")
}
}
@@ -0,0 +1,146 @@
/**
* File: my_list.swift
* Created Time: 2023-01-08
* Author: nuomi1 (nuomi1@qq.com)
*/
/* */
class MyList {
private var arr: [Int] //
private var _capacity: Int //
private var _size: Int //
private let extendRatio: Int //
/* */
init() {
_capacity = 10
_size = 0
extendRatio = 2
arr = Array(repeating: 0, count: _capacity)
}
/* */
func size() -> Int {
_size
}
/* */
func capacity() -> Int {
_capacity
}
/* */
func get(index: Int) -> Int {
//
if index < 0 || index >= size() {
fatalError("索引越界")
}
return arr[index]
}
/* */
func set(index: Int, num: Int) {
if index < 0 || index >= size() {
fatalError("索引越界")
}
arr[index] = num
}
/* */
func add(num: Int) {
//
if size() == capacity() {
extendCapacity()
}
arr[size()] = num
//
_size += 1
}
/* */
func insert(index: Int, num: Int) {
if index < 0 || index >= size() {
fatalError("索引越界")
}
//
if size() == capacity() {
extendCapacity()
}
// index
for j in (index ..< size()).reversed() {
arr[j + 1] = arr[j]
}
arr[index] = num
//
_size += 1
}
/* */
@discardableResult
func remove(index: Int) -> Int {
if index < 0 || index >= size() {
fatalError("索引越界")
}
let num = arr[index]
// index
for j in index ..< (size() - 1) {
arr[j] = arr[j + 1]
}
//
_size -= 1
//
return num
}
/* */
func extendCapacity() {
// extendRatio
arr = arr + Array(repeating: 0, count: capacity() * (extendRatio - 1))
//
_capacity = arr.count
}
/* */
func toArray() -> [Int] {
Array(arr.prefix(size()))
}
}
@main
enum _MyList {
/* Driver Code */
static func main() {
/* */
let nums = MyList()
/* */
nums.add(num: 1)
nums.add(num: 3)
nums.add(num: 2)
nums.add(num: 5)
nums.add(num: 4)
print("串列 nums = \(nums.toArray()) ,容量 = \(nums.capacity()) ,長度 = \(nums.size())")
/* */
nums.insert(index: 3, num: 6)
print("在索引 3 處插入數字 6 ,得到 nums = \(nums.toArray())")
/* */
nums.remove(index: 3)
print("刪除索引 3 處的元素,得到 nums = \(nums.toArray())")
/* */
let num = nums.get(index: 1)
print("訪問索引 1 處的元素,得到 num = \(num)")
/* */
nums.set(index: 1, num: 0)
print("將索引 1 處的元素更新為 0 ,得到 nums = \(nums.toArray())")
/* */
for i in 0 ..< 10 {
// i = 5
nums.add(num: i)
}
print("擴容後的串列 nums = \(nums.toArray()) ,容量 = \(nums.capacity()) ,長度 = \(nums.size())")
}
}