Skip to content

Commit

Permalink
binary tree definations
Browse files Browse the repository at this point in the history
  • Loading branch information
fasionchan committed Jul 29, 2019
1 parent 0f64bcd commit 3e1a6ba
Show file tree
Hide file tree
Showing 17 changed files with 224 additions and 6 deletions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions docs/zh_CN/_templates/more.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,26 @@ <h3>更多阅读</h3>
"title": "Go语言小册",
"url": "https://golang-book.readthedocs.io/zh_CN/latest/",
},
{
"title": "学习Linux",
"url": "https://learn-linux.readthedocs.io/zh_CN/latest/",
},
{
"title": "Linux网络编程",
"url": "https://linux-network-programming.readthedocs.io/zh_CN/latest/",
},
{
"title": "NodeJs小册",
"url": "https://nodejs-book.readthedocs.io/zh_CN/latest/",
},
{
"title": "OSX操作指南",
"url": "https://osx-guide.readthedocs.io/zh_CN/latest/",
},
{
"title": "Python语言小册",
"url": "https://python-book.readthedocs.io/zh_CN/latest/",
},
] %}
<li class="toctree-l1"><a class="reference internal" href="{{ link.url }}">{{ link.title }}</a ></li>
{% endfor %}
Expand Down
1 change: 1 addition & 0 deletions docs/zh_CN/about/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
:maxdepth: 2

交流 <contact>
推荐书单 <../appendices/recommended-books>

.. comments
comment something out blow
Expand Down
29 changes: 29 additions & 0 deletions docs/zh_CN/appendices/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.. 附录
FileName: index.rst
Author: Fasion Chan
Created: 2018-03-03 11:45:04
@contact: fasionchan@gmail.com
@version: $Id$
Description:
Changelog:
Note:
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
.. meta::
:keywords: Data Structure, Algorithm, C++, Javascript, Python, 数据结构, 算法

====
附录
====

.. toctree::
:titlesonly:

推荐书单 <recommended-books>

.. comments
comment something out below
53 changes: 53 additions & 0 deletions docs/zh_CN/appendices/recommended-books.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
.. 推荐书单
FileName: index.rst
Author: Fasion Chan
Created: 2018-03-03 11:45:04
@contact: fasionchan@gmail.com
@version: $Id$
Description:
Changelog:
Note:
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
.. meta::
:description lang=zh:
数据结构与算法学习推荐书单,涵盖基础理论与C、C++、Java、Javascript等语言描述。
:keywords: Data Structure, Algorithm, C++, Javascript, Python, 数据结构, 算法, 推荐书单

========
推荐书单
========

.. figure:: /_images/appendices/recommended-books/9d86001ba8d64425e44fb1a40c95cce2.jpg
:width: 160px
:target: https://book.douban.com/subject/20432061/

*算法导论*
👉 `豆瓣 <https://book.douban.com/subject/20432061/>`__

C++
===

.. figure:: /_images/appendices/recommended-books/86c9860fb895d6c391e461f975f60157.jpg
:width: 160px
:target: https://book.douban.com/subject/25956449/

*数据结构与算法分析(C++版)*
👉 `豆瓣 <https://book.douban.com/subject/25956449/>`__

下一步
======

.. include:: /_fragments/next-step-to-wechat-mp.rst

.. include:: /_fragments/disqus.rst

.. include:: /_fragments/wechat-reward.rst

.. comments
comment something out below
115 changes: 115 additions & 0 deletions docs/zh_CN/binary-tree/definations.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
..
Author: fasion
Created time: 2019-07-28 19:46:17
Last Modified by: fasion
Last Modified time: 2019-07-29 16:37:36
.. meta::
:description lang=zh:
本文讨论二叉树相关术语,包括根、父子节点、叶子节点、高度、深度等;
并介绍两个特殊的二叉树形态——满二叉树以及完全二叉树。
:keywords: binary tree, full binary tree, complete binary tree, root, parent, child, ancestor, descendent, height, depth, level, terminology, 二叉树, 满二叉树, 完全二叉树, 根, 父节点, 子节点, 祖先节点, 子孙节点, 高度, 深度, 层, 术语

==========
二叉树定义
==========

术语
====

.. figure:: /_images/binary-tree/definations/4ee27714ed5cc57475d9f359025585d1.jpg

- **** ( `root` ),即 *A* ,为树中 **最顶节点** ,该节点 **没有父节点** ;
- *A* 为 *B* 的 **父节点** ( `parent` );
- *E* 为 *B* 的 **子节点** ( `child` );
- *A* 、 *B* 为 *E* 的 **祖先节点** ( `ancestor` );
- *B* 、 *E* 为 *A* 的 **子孙节点** ( `descendent` );
- *I* 、 *J* 互为 **兄弟节点** ( `sibling` ), **父节点相同** ;
- **高度** ( `height` ),节点到最远子孙的距离;
- *A* 高度为 *3* ;
- *H* 高度为 *1* ;
- *I* 高度为 *0* ;
- **深度** ( `Depth` ),节点到根的距离;
- *A* 深度为 *0* ;
- *H* 深度为 *2* ;
- *I* 高度为 *3* ;
- 节点可按深度分 **** ( `level` );
- 根为第 *0* 层;
- *I* 、 *J* 为第 *3* 层;
- *H* 及其全部子孙节点组成一颗 **子树** ( `subtree` );


满二叉树
========

**满二叉树** ( `Full Binary Tree` )中,每个节点要么没有子节点( `child` ),要么有两个子节点。

.. figure:: /_images/binary-tree/definations/020e6de667d476f113ce0115658f4a6c.png

*满二叉树*

完全二叉树
==========

**完全二叉树** ( `Complete Binary Tree` ),有以下两个性质:

#. 除了最后一层,其他所有层都是满的;
#. 最后一层节点尽可能地靠着最左边;

.. figure:: /_images/binary-tree/definations/142023250664309e83c15e256ca9456a.png

*完全二叉树*

由于完全二叉树逐层从左到右排列, 因此对于给定节点数的树, **形态只有一种** 。
因此,完全二叉树可以用一个数组来表示:

.. figure:: /_images/binary-tree/definations/f1e5132ea80d1e751cd0c5497083f801.png

*完全二叉树数组表示*

为每个节点编号, **根节点** 为 *0* ,那么编号即是节点在数组中的 **下标** :

.. figure:: /_images/binary-tree/definations/e47d6b47f107cba8c5d4fea91967021b.png

对于节点 :math:`i` ,其:

- **父节点** 为: :math:`\frac{i - 1}{2}` ;
- **左子节点** 为: :math:`2i + 1` ;
- **右子节点** 为: :math:`2i + 2` ;

下一步
======

.. include:: /_fragments/next-step-to-wechat-mp.rst

.. include:: /_fragments/disqus.rst

.. include:: /_fragments/wechat-reward.rst

.. comments
comment something out below
.. figure:: /_images/binary-tree/definations/7f3bd013112cd06401a43ab4ba888d6f.png
树中唯一没有父节点的节点为 **根节点** ( `root` ),如图节点 *0* 。
**路径** ( *Path* )
- **路径** ( `path` ),;
*A* 、 *G* 的路径为 *ADG* ;
.. figure:: /_images/binary-tree/definations/7f3bd013112cd06401a43ab4ba888d6f.png
对于上图节点 *3* ,
- 节点 *1* 是 **父节点** ( `parent` );
- 节点 *4* 是 **兄弟节点** ( `sibling` );
- 节点 *6* 是 **左子节点** ( `left child` );
- 节点 *7* 是 **右子节点** ( `right child` );
另外,节点还可以分成:
- **根节点** ( `root` ),树中唯一 **没有父节点** 的节点;
- **叶子节点** ( `leaf` ),没有子节点;
- **内部节点** ( `internal` ),至少有一个子节点;
3 changes: 2 additions & 1 deletion docs/zh_CN/binary-tree/index.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. 关于
.. 二叉树
FileName: index.rst
Author: Fasion Chan
Created: 2018-08-27 20:08:14
Expand All @@ -18,6 +18,7 @@
.. toctree::
:titlesonly:

定义 <definations>
遍历二叉树 <traverse>
重建二叉树 <rebuild>

Expand Down
3 changes: 1 addition & 2 deletions docs/zh_CN/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
队列 <queue/index>
二叉树 <binary-tree/index>
排序 <sorting/index>


附录 <appendices/index>

.. comments
comment something out below
Expand Down
7 changes: 5 additions & 2 deletions docs/zh_CN/list/array-list/generic-array-list-java.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
======

泛型编程的思想是,在实现类或方法时,暂时不指定类型,而是稍后再决定使用什么类型。
为达到这个目的,需要借助类型参数,以尖括号括住,位于类名之后:
为达到这个目的,需要借助 **类型参数** ,位于类名之后,以尖括号括住

.. literalinclude:: /_src/java/list/GenericArrayList/GenericArrayList.java
:language: java
Expand Down Expand Up @@ -64,7 +64,7 @@
:lines: 40-51
:linenos:

最后,使用该类实例化对象时,通过尖括号确定实际类型。
最后,创建该类对象时,通过尖括号确定实际类型。

例如,创建一个存储整数的数组表对象:

Expand All @@ -84,6 +84,9 @@
:lines: 106
:linenos:

下一步
======

.. include:: /_fragments/next-step-to-wechat-mp.rst

.. include:: /_fragments/disqus.rst
Expand Down
3 changes: 2 additions & 1 deletion docs/zh_CN/list/array-list/naive-array-list-java.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
.. meta::
:description lang=zh:
:keywords:
朴素数组表(Naive Array List)是本文自创的名词,表示一种最直观最原始的数组表。
:keywords: Data Structure, Array, Dynamic Array, Array List, Java

====================
朴素数组表(Java语言)
Expand Down

0 comments on commit 3e1a6ba

Please sign in to comment.