mirror of
https://github.com/krahets/hello-algo.git
synced 2026-08-21 07:47:14 +00:00
build
This commit is contained in:
@@ -4,142 +4,139 @@ comments: true
|
||||
|
||||
# 16.3 Glossary
|
||||
|
||||
The following table lists important terms that appear in this book. It is worth noting the following points:
|
||||
|
||||
- We recommend remembering the English terms to help with reading English-language literature.
|
||||
- Some terms have different names in Simplified Chinese and Traditional Chinese.
|
||||
The following table lists important terms that appear in this book.
|
||||
|
||||
<p align="center"> Table 16-1 Important Terms in Data Structures and Algorithms </p>
|
||||
|
||||
<div class="center-table" markdown>
|
||||
|
||||
| English | Simplified Chinese | Traditional Chinese |
|
||||
| ------------------------------ | ------------------ | ------------------- |
|
||||
| algorithm | 算法 | 演算法 |
|
||||
| data structure | 数据结构 | 資料結構 |
|
||||
| code | 代码 | 程式碼 |
|
||||
| file | 文件 | 檔案 |
|
||||
| function | 函数 | 函式 |
|
||||
| method | 方法 | 方法 |
|
||||
| variable | 变量 | 變數 |
|
||||
| asymptotic complexity analysis | 渐近复杂度分析 | 漸近複雜度分析 |
|
||||
| time complexity | 时间复杂度 | 時間複雜度 |
|
||||
| space complexity | 空间复杂度 | 空間複雜度 |
|
||||
| loop | 循环 | 迴圈 |
|
||||
| iteration | 迭代 | 迭代 |
|
||||
| recursion | 递归 | 遞迴 |
|
||||
| tail recursion | 尾递归 | 尾遞迴 |
|
||||
| recursion tree | 递归树 | 遞迴樹 |
|
||||
| big-$O$ notation | 大 $O$ 记号 | 大 $O$ 記號 |
|
||||
| asymptotic upper bound | 渐近上界 | 漸近上界 |
|
||||
| sign-magnitude | 原码 | 原碼 |
|
||||
| 1’s complement | 反码 | 一補數 |
|
||||
| 2’s complement | 补码 | 二補數 |
|
||||
| array | 数组 | 陣列 |
|
||||
| index | 索引 | 索引 |
|
||||
| linked list | 链表 | 鏈結串列 |
|
||||
| linked list node, list node | 链表节点 | 鏈結串列節點 |
|
||||
| head node | 头节点 | 頭節點 |
|
||||
| tail node | 尾节点 | 尾節點 |
|
||||
| list | 列表 | 串列 |
|
||||
| dynamic array | 动态数组 | 動態陣列 |
|
||||
| hard disk | 硬盘 | 硬碟 |
|
||||
| random-access memory (RAM) | 内存 | 記憶體 |
|
||||
| cache memory | 缓存 | 快取 |
|
||||
| cache miss | 缓存未命中 | 快取未命中 |
|
||||
| cache hit rate | 缓存命中率 | 快取命中率 |
|
||||
| stack | 栈 | 堆疊 |
|
||||
| top of the stack | 栈顶 | 堆疊頂 |
|
||||
| bottom of the stack | 栈底 | 堆疊底 |
|
||||
| queue | 队列 | 佇列 |
|
||||
| double-ended queue | 双向队列 | 雙向佇列 |
|
||||
| front of the queue | 队首 | 佇列首 |
|
||||
| rear of the queue | 队尾 | 佇列尾 |
|
||||
| hash table | 哈希表 | 雜湊表 |
|
||||
| hash set | 哈希集合 | 雜湊集合 |
|
||||
| bucket | 桶 | 桶 |
|
||||
| hash function | 哈希函数 | 雜湊函式 |
|
||||
| hash collision | 哈希冲突 | 雜湊衝突 |
|
||||
| load factor | 负载因子 | 負載因子 |
|
||||
| separate chaining | 链式地址 | 鏈結位址 |
|
||||
| open addressing | 开放寻址 | 開放定址 |
|
||||
| linear probing | 线性探测 | 線性探查 |
|
||||
| lazy deletion | 懒删除 | 懶刪除 |
|
||||
| binary tree | 二叉树 | 二元樹 |
|
||||
| tree node | 树节点 | 樹節點 |
|
||||
| left-child node | 左子节点 | 左子節點 |
|
||||
| right-child node | 右子节点 | 右子節點 |
|
||||
| parent node | 父节点 | 父節點 |
|
||||
| left subtree | 左子树 | 左子樹 |
|
||||
| right subtree | 右子树 | 右子樹 |
|
||||
| root node | 根节点 | 根節點 |
|
||||
| leaf node | 叶节点 | 葉節點 |
|
||||
| edge | 边 | 邊 |
|
||||
| level | 层 | 層 |
|
||||
| degree | 度 | 度 |
|
||||
| height | 高度 | 高度 |
|
||||
| depth | 深度 | 深度 |
|
||||
| perfect binary tree | 完美二叉树 | 完美二元樹 |
|
||||
| complete binary tree | 完全二叉树 | 完全二元樹 |
|
||||
| full binary tree | 完满二叉树 | 完滿二元樹 |
|
||||
| balanced binary tree | 平衡二叉树 | 平衡二元樹 |
|
||||
| binary search tree | 二叉搜索树 | 二元搜尋樹 |
|
||||
| AVL tree | AVL 树 | AVL 樹 |
|
||||
| red-black tree | 红黑树 | 紅黑樹 |
|
||||
| level-order traversal | 层序遍历 | 層序走訪 |
|
||||
| breadth-first traversal | 广度优先遍历 | 廣度優先走訪 |
|
||||
| depth-first traversal | 深度优先遍历 | 深度優先走訪 |
|
||||
| binary search tree | 二叉搜索树 | 二元搜尋樹 |
|
||||
| balanced binary search tree | 平衡二叉搜索树 | 平衡二元搜尋樹 |
|
||||
| balance factor | 平衡因子 | 平衡因子 |
|
||||
| heap | 堆 | 堆積 |
|
||||
| max heap | 大顶堆 | 大頂堆積 |
|
||||
| min heap | 小顶堆 | 小頂堆積 |
|
||||
| priority queue | 优先队列 | 優先佇列 |
|
||||
| heapify | 堆化 | 堆積化 |
|
||||
| top-$k$ problem | Top-$k$ 问题 | Top-$k$ 問題 |
|
||||
| graph | 图 | 圖 |
|
||||
| vertex | 顶点 | 頂點 |
|
||||
| undirected graph | 无向图 | 無向圖 |
|
||||
| directed graph | 有向图 | 有向圖 |
|
||||
| connected graph | 连通图 | 連通圖 |
|
||||
| disconnected graph | 非连通图 | 非連通圖 |
|
||||
| weighted graph | 有权图 | 有權圖 |
|
||||
| adjacency | 邻接 | 鄰接 |
|
||||
| path | 路径 | 路徑 |
|
||||
| in-degree | 入度 | 入度 |
|
||||
| out-degree | 出度 | 出度 |
|
||||
| adjacency matrix | 邻接矩阵 | 鄰接矩陣 |
|
||||
| adjacency list | 邻接表 | 鄰接表 |
|
||||
| breadth-first search | 广度优先搜索 | 廣度優先搜尋 |
|
||||
| depth-first search | 深度优先搜索 | 深度優先搜尋 |
|
||||
| binary search | 二分查找 | 二分搜尋 |
|
||||
| searching algorithm | 搜索算法 | 搜尋演算法 |
|
||||
| sorting algorithm | 排序算法 | 排序演算法 |
|
||||
| selection sort | 选择排序 | 選擇排序 |
|
||||
| bubble sort | 冒泡排序 | 泡沫排序 |
|
||||
| insertion sort | 插入排序 | 插入排序 |
|
||||
| quick sort | 快速排序 | 快速排序 |
|
||||
| merge sort | 归并排序 | 合併排序 |
|
||||
| heap sort | 堆排序 | 堆積排序 |
|
||||
| bucket sort | 桶排序 | 桶排序 |
|
||||
| counting sort | 计数排序 | 計數排序 |
|
||||
| radix sort | 基数排序 | 基數排序 |
|
||||
| divide and conquer | 分治 | 分治 |
|
||||
| hanota problem | 汉诺塔问题 | 河內塔問題 |
|
||||
| backtracking algorithm | 回溯算法 | 回溯演算法 |
|
||||
| constraint | 约束 | 約束 |
|
||||
| solution | 解 | 解 |
|
||||
| state | 状态 | 狀態 |
|
||||
| pruning | 剪枝 | 剪枝 |
|
||||
| permutations problem | 全排列问题 | 全排列問題 |
|
||||
| subset-sum problem | 子集和问题 | 子集合問題 |
|
||||
| $n$-queens problem | $n$ 皇后问题 | $n$ 皇后問題 |
|
||||
| dynamic programming | 动态规划 | 動態規劃 |
|
||||
| initial state | 初始状态 | 初始狀態 |
|
||||
| state-transition equation | 状态转移方程 | 狀態轉移方程 |
|
||||
| knapsack problem | 背包问题 | 背包問題 |
|
||||
| edit distance problem | 编辑距离问题 | 編輯距離問題 |
|
||||
| greedy algorithm | 贪心算法 | 貪婪演算法 |
|
||||
| English |
|
||||
| ------------------------------ |
|
||||
| algorithm |
|
||||
| data structure |
|
||||
| code |
|
||||
| file |
|
||||
| function |
|
||||
| method |
|
||||
| variable |
|
||||
| asymptotic complexity analysis |
|
||||
| time complexity |
|
||||
| space complexity |
|
||||
| loop |
|
||||
| iteration |
|
||||
| recursion |
|
||||
| tail recursion |
|
||||
| recursion tree |
|
||||
| big-$O$ notation |
|
||||
| asymptotic upper bound |
|
||||
| sign-magnitude |
|
||||
| 1’s complement |
|
||||
| 2’s complement |
|
||||
| array |
|
||||
| index |
|
||||
| linked list |
|
||||
| linked list node, list node |
|
||||
| head node |
|
||||
| tail node |
|
||||
| list |
|
||||
| dynamic array |
|
||||
| hard disk |
|
||||
| random-access memory (RAM) |
|
||||
| cache memory |
|
||||
| cache miss |
|
||||
| cache hit rate |
|
||||
| stack |
|
||||
| top of the stack |
|
||||
| bottom of the stack |
|
||||
| queue |
|
||||
| double-ended queue |
|
||||
| front of the queue |
|
||||
| rear of the queue |
|
||||
| hash table |
|
||||
| hash set |
|
||||
| bucket |
|
||||
| hash function |
|
||||
| hash collision |
|
||||
| load factor |
|
||||
| separate chaining |
|
||||
| open addressing |
|
||||
| linear probing |
|
||||
| lazy deletion |
|
||||
| binary tree |
|
||||
| tree node |
|
||||
| left-child node |
|
||||
| right-child node |
|
||||
| parent node |
|
||||
| left subtree |
|
||||
| right subtree |
|
||||
| root node |
|
||||
| leaf node |
|
||||
| edge |
|
||||
| level |
|
||||
| degree |
|
||||
| height |
|
||||
| depth |
|
||||
| perfect binary tree |
|
||||
| complete binary tree |
|
||||
| full binary tree |
|
||||
| balanced binary tree |
|
||||
| binary search tree |
|
||||
| AVL tree |
|
||||
| red-black tree |
|
||||
| level-order traversal |
|
||||
| breadth-first traversal |
|
||||
| depth-first traversal |
|
||||
| binary search tree |
|
||||
| balanced binary search tree |
|
||||
| balance factor |
|
||||
| heap |
|
||||
| max heap |
|
||||
| min heap |
|
||||
| priority queue |
|
||||
| heapify |
|
||||
| top-$k$ problem |
|
||||
| graph |
|
||||
| vertex |
|
||||
| undirected graph |
|
||||
| directed graph |
|
||||
| connected graph |
|
||||
| disconnected graph |
|
||||
| weighted graph |
|
||||
| adjacency |
|
||||
| path |
|
||||
| in-degree |
|
||||
| out-degree |
|
||||
| adjacency matrix |
|
||||
| adjacency list |
|
||||
| breadth-first search |
|
||||
| depth-first search |
|
||||
| binary search |
|
||||
| searching algorithm |
|
||||
| sorting algorithm |
|
||||
| selection sort |
|
||||
| bubble sort |
|
||||
| insertion sort |
|
||||
| quick sort |
|
||||
| merge sort |
|
||||
| heap sort |
|
||||
| bucket sort |
|
||||
| counting sort |
|
||||
| radix sort |
|
||||
| divide and conquer |
|
||||
| hanota problem |
|
||||
| backtracking algorithm |
|
||||
| constraint |
|
||||
| solution |
|
||||
| state |
|
||||
| pruning |
|
||||
| permutations problem |
|
||||
| subset-sum problem |
|
||||
| $n$-queens problem |
|
||||
| dynamic programming |
|
||||
| initial state |
|
||||
| state-transition equation |
|
||||
| knapsack problem |
|
||||
| edit distance problem |
|
||||
| greedy algorithm |
|
||||
|
||||
</div>
|
||||
|
||||
@@ -812,8 +812,8 @@ Let the input data size be $n$. The following figure shows common types of space
|
||||
|
||||
$$
|
||||
\begin{aligned}
|
||||
O(1) < O(\log n) < O(n) < O(n^2) < O(2^n) \newline
|
||||
\text{Constant} < \text{Logarithmic} < \text{Linear} < \text{Quadratic} < \text{Exponential}
|
||||
& O(1) < O(\log n) < O(n) < O(n^2) < O(2^n) \newline
|
||||
& \text{Constant} < \text{Logarithmic} < \text{Linear} < \text{Quadratic} < \text{Exponential}
|
||||
\end{aligned}
|
||||
$$
|
||||
|
||||
|
||||
@@ -1004,8 +1004,8 @@ Let the input data size be $n$. Common time complexity types are shown in Figure
|
||||
|
||||
$$
|
||||
\begin{aligned}
|
||||
O(1) < O(\log n) < O(n) < O(n \log n) < O(n^2) < O(2^n) < O(n!) \newline
|
||||
\text{Constant} < \text{Logarithmic} < \text{Linear} < \text{Linearithmic} < \text{Quadratic} < \text{Exponential} < \text{Factorial}
|
||||
& O(1) < O(\log n) < O(n) < O(n \log n) < O(n^2) < O(2^n) < O(n!) \newline
|
||||
& \text{Constant} < \text{Logarithmic} < \text{Linear} < \text{Linearithmic} < \text{Quadratic} < \text{Exponential} < \text{Factorial}
|
||||
\end{aligned}
|
||||
$$
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ comments: true
|
||||
|
||||
In computers, all data is stored in binary form, and character `char` is no exception. To represent characters, we need to establish a "character set" that defines a one-to-one correspondence between each character and binary numbers. With a character set, computers can convert binary numbers to characters by looking up the table.
|
||||
|
||||
## 3.4.1 Ascii Character Set
|
||||
## 3.4.1 ASCII Character Set
|
||||
|
||||
<u>ASCII code</u> is the earliest character set, with the full name American Standard Code for Information Interchange. It uses 7 binary bits (the lower 7 bits of one byte) to represent a character, and can represent a maximum of 128 different characters. As shown in Figure 3-6, ASCII code includes uppercase and lowercase English letters, numbers 0 ~ 9, some punctuation marks, and some control characters (such as newline and tab).
|
||||
|
||||
@@ -18,7 +18,7 @@ However, **ASCII code can only represent English**. With the globalization of co
|
||||
|
||||
Worldwide, a batch of EASCII character sets suitable for different regions have appeared successively. The first 128 characters of these character sets are unified as ASCII code, and the last 128 characters are defined differently to adapt to the needs of different languages.
|
||||
|
||||
## 3.4.2 Gbk Character Set
|
||||
## 3.4.2 GBK Character Set
|
||||
|
||||
Later, people found that **EASCII still could not provide enough characters for many languages**. For example, there are nearly one hundred thousand Chinese characters, and several thousand are used in everyday life. In 1980, the China National Standardization Administration released the <u>GB2312</u> character set, which included 6,763 Chinese characters, basically meeting the needs of computer processing for Chinese.
|
||||
|
||||
@@ -30,7 +30,7 @@ With the vigorous development of computer technology, character sets and encodin
|
||||
|
||||
Researchers of that era thought: **If a sufficiently complete character set were released to include all languages and symbols in the world, wouldn't that solve problems in cross-language environments and eliminate garbled text**? Driven by this idea, a large and comprehensive character set, Unicode, was born.
|
||||
|
||||
<u>Unicode</u> is called "统一码" (Unified Code) in Chinese and can theoretically accommodate over one million characters. It is committed to including characters from around the world into a unified character set, providing a universal character set to handle and display various language texts, reducing garbled character problems caused by different encoding standards.
|
||||
<u>Unicode</u>, or Unified Code, can theoretically accommodate over one million characters. It is committed to including characters from around the world into a unified character set, providing a universal character set to handle and display various language texts, reducing garbled character problems caused by different encoding standards.
|
||||
|
||||
Since its release in 1991, Unicode has continuously expanded to include new languages and characters. As of September 2022, Unicode has included 149,186 characters, including characters, symbols, and even emojis from various languages. In practical storage and encoding schemes for this vast character set, commonly used characters often occupy 2 bytes, while some rare characters occupy 3 bytes or even 4 bytes.
|
||||
|
||||
@@ -44,7 +44,7 @@ For the above problem, **a straightforward solution is to store all characters a
|
||||
|
||||
However, ASCII code has already proven to us that encoding English only requires 1 byte. If the above scheme is adopted, the size of English text will be twice that under ASCII encoding, which is very wasteful of memory space. Therefore, we need a more efficient Unicode encoding method.
|
||||
|
||||
## 3.4.4 Utf-8 Encoding
|
||||
## 3.4.4 UTF-8 Encoding
|
||||
|
||||
Currently, UTF-8 has become the most widely used Unicode encoding method internationally. **It is a variable-length encoding** that uses 1 to 4 bytes to represent a character, depending on the complexity of the character. ASCII characters only require 1 byte, Latin and Greek letters require 2 bytes, commonly used Chinese characters require 3 bytes, and some other rare characters require 4 bytes.
|
||||
|
||||
@@ -53,7 +53,7 @@ The encoding rules of UTF-8 are not complicated and can be divided into the foll
|
||||
- For 1-byte characters, set the highest bit to $0$, and set the remaining 7 bits to the Unicode code point. It is worth noting that ASCII characters occupy the first 128 code points in the Unicode character set. That is to say, **UTF-8 encoding is backward compatible with ASCII code**. This means we can use UTF-8 to parse very old ASCII code text.
|
||||
- For characters with a length of $n$ bytes (where $n > 1$), set the highest $n$ bits of the first byte to $1$, and set the $(n + 1)$-th bit to $0$; starting from the second byte, set the highest 2 bits of each byte to $10$; use all remaining bits to fill in the Unicode code point of the character.
|
||||
|
||||
Figure 3-8 shows the UTF-8 encoding corresponding to "Hello算法". It can be observed that since the highest $n$ bits are all set to $1$, the system can determine that the character length is $n$ by counting the leading $1$ bits.
|
||||
Figure 3-8 shows the UTF-8 encoding corresponding to "Hello 算法". It can be observed that since the highest $n$ bits are all set to $1$, the system can determine that the character length is $n$ by counting the leading $1$ bits.
|
||||
|
||||
But why set the highest 2 bits of all other bytes to $10$? In fact, this $10$ can serve as a check symbol. Assuming the system starts parsing text from an incorrect byte, the $10$ at the beginning of the byte can help the system quickly determine an anomaly.
|
||||
|
||||
|
||||
@@ -65,6 +65,6 @@ $$
|
||||
|
||||
In summary, both "first negate then add 1" and "first subtract 1 then negate" are computing the complement to $10000$, and they are equivalent.
|
||||
|
||||
Essentially, the "negate" operation is actually finding the complement to $1111$ (because `sign-magnitude + 1's complement = 1111` always holds); and adding 1 to the 1's complement yields the 2's complement, which is the complement to $10000$.
|
||||
Essentially, the "negate" operation is actually finding the complement to $1111$ (because "sign-magnitude + 1's complement = 1111" always holds); and adding 1 to the 1's complement yields the 2's complement, which is the complement to $10000$.
|
||||
|
||||
The above uses $n = 4$ as an example, and it can be generalized to binary numbers of any number of bits.
|
||||
|
||||
@@ -3,9 +3,9 @@ comments: true
|
||||
icon: material/table-search
|
||||
---
|
||||
|
||||
# Chapter 6. Hash Table
|
||||
# Chapter 6. Hashing
|
||||
|
||||
{ class="cover-image" }
|
||||
{ class="cover-image" }
|
||||
|
||||
!!! abstract
|
||||
|
||||
|
||||
Reference in New Issue
Block a user