diff --git a/notes/pics/hanoi-start.png b/notes/pics/hanoi-start.png new file mode 100644 index 00000000..174cd5f4 Binary files /dev/null and b/notes/pics/hanoi-start.png differ diff --git a/notes/pics/hanoi-step1.png b/notes/pics/hanoi-step1.png new file mode 100644 index 00000000..7d26a002 Binary files /dev/null and b/notes/pics/hanoi-step1.png differ diff --git a/notes/pics/hanoi-step2.png b/notes/pics/hanoi-step2.png new file mode 100644 index 00000000..e175609c Binary files /dev/null and b/notes/pics/hanoi-step2.png differ diff --git a/notes/pics/hanoi-step3.png b/notes/pics/hanoi-step3.png new file mode 100644 index 00000000..c97c5647 Binary files /dev/null and b/notes/pics/hanoi-step3.png differ diff --git a/notes/pics/huffman-tree.png b/notes/pics/huffman-tree.png new file mode 100644 index 00000000..5aa32115 Binary files /dev/null and b/notes/pics/huffman-tree.png differ diff --git a/notes/算法 - 其它.md b/notes/算法 - 其它.md index 4e295c90..14ebbe38 100644 --- a/notes/算法 - 其它.md +++ b/notes/算法 - 其它.md @@ -1,7 +1,7 @@ # 算法 - 其它 ## 汉诺塔 -

+

有三个柱子,分别为 from、buffer、to。需要将 from 上的圆盘全部移动到 to 上,并且要保证小圆盘始终在大圆盘上。 @@ -9,15 +9,15 @@ ① 将 n-1 个圆盘从 from -\> buffer -

+

② 将 1 个圆盘从 from -\> to -

+

③ 将 n-1 个圆盘从 buffer -\> to -

+

如果只有一个圆盘,那么只需要进行一次移动操作。 @@ -41,7 +41,7 @@ public class Hanoi { } ``` -```html +```text from H1 to H3 from H1 to H2 from H3 to H2 @@ -68,7 +68,7 @@ from H1 to H3 生成编码时,从根节点出发,向左遍历则添加二进制位 0,向右则添加二进制位 1,直到遍历到叶子节点,叶子节点代表的字符的编码就是这个路径编码。 -

+

```java public class Huffman { @@ -127,3 +127,8 @@ public class Huffman { } } ``` + +## 参考资料 + +- Sedgewick R, Wayne K. 算法(第 4 版)[M]. 人民邮电出版社, 2012. +- [Algorithms, 4th Edition](https://algs4.cs.princeton.edu/home/)