diff --git a/408/数据结构/6 树和二叉树/6 树和二叉树.md b/408/数据结构/6 树和二叉树/6 树和二叉树.md index e708215..4cd0848 100644 --- a/408/数据结构/6 树和二叉树/6 树和二叉树.md +++ b/408/数据结构/6 树和二叉树/6 树和二叉树.md @@ -42,22 +42,7 @@ ### 6.1① 已知一棵树边的集合为 $\{ , , , , , , , , , , , , \}$,请画出这棵树,并回答下列问题: -```mermaid -graph TB -A --- B -A --- C -B --- D -B --- E -C --- F -C --- G -C --- H -E --- I -G --- J -G --- K -H --- L -I --- M -I --- N -``` + #### (1)哪个是根结点? @@ -158,8 +143,8 @@ $$ | :-------------: | :---------------: | :---------------: | :---------------: | | $n$ 在 $m$ 左方 | 1 | 1 | 1 | | $n$ 在 $m$ 右方 | 0 | 0 | 0 | -| $n$ 是 $m$ 祖先 | 1 | φ | φ | -| $n$ 是 $m$ 子孙 | 1 | φ | φ | +| $n$ 是 $m$ 祖先 | 1 | φ | 0 | +| $n$ 是 $m$ 子孙 | 0 | φ | 1 | > 注:如果 ① 离 a 和 b 最近的共同祖先 p 存在,且 ② a 在 p 的左子树中,b 在 p 的右子树中,则称 a 在 b 的左方(即 b 在 a 的右方)。 @@ -167,10 +152,7 @@ $$ #### (a)它们在先序遍历和中序遍历时,得到的结点访问序列相同; -```mermaid -graph TB -1(1) -``` + #### (b)它们在后序遍历和中序遍历时,得到的结点访问序列相同; diff --git a/408/数据结构/6 树和二叉树/assets/6.14.a.dot b/408/数据结构/6 树和二叉树/assets/6.14.a.dot new file mode 100644 index 0000000..2ba554a --- /dev/null +++ b/408/数据结构/6 树和二叉树/assets/6.14.a.dot @@ -0,0 +1,11 @@ +graph a { + splines="FALSE"; + + /* Entities */ + 1[shape = circle] + + /* Relationships */ + 1 + + /* Ranks */ +} \ No newline at end of file diff --git a/408/数据结构/6 树和二叉树/assets/6.14.a.png b/408/数据结构/6 树和二叉树/assets/6.14.a.png new file mode 100644 index 0000000..e1abcb1 Binary files /dev/null and b/408/数据结构/6 树和二叉树/assets/6.14.a.png differ diff --git a/408/数据结构/6 树和二叉树/assets/6.19.dot b/408/数据结构/6 树和二叉树/assets/6.19.dot new file mode 100644 index 0000000..a207226 --- /dev/null +++ b/408/数据结构/6 树和二叉树/assets/6.19.dot @@ -0,0 +1,36 @@ +graph 6.19 { + splines="FALSE"; + + /* Entities */ + A [shape = circle] + B [shape = circle] + C [shape = circle] + D [shape = circle] + E [shape = circle] + F [shape = circle] + G [shape = circle] + H [shape = circle] + I [shape = circle] + J [shape = circle] + K [shape = circle] + L [shape = circle] + M [shape = circle] + N [shape = circle] + + /* Relationships */ + A -- B + A -- C + B -- D + B -- E + C -- F + C -- G + C -- H + E -- I + G -- J + G -- K + H -- L + I -- M + I -- N + + /* Ranks */ +} \ No newline at end of file diff --git a/408/数据结构/6 树和二叉树/assets/6.19.png b/408/数据结构/6 树和二叉树/assets/6.19.png new file mode 100644 index 0000000..9a49715 Binary files /dev/null and b/408/数据结构/6 树和二叉树/assets/6.19.png differ diff --git a/408/数据结构/6 树和二叉树/assets/6.3.dot b/408/数据结构/6 树和二叉树/assets/6.3.dot new file mode 100644 index 0000000..a9e1d1e --- /dev/null +++ b/408/数据结构/6 树和二叉树/assets/6.3.dot @@ -0,0 +1,29 @@ +graph 6.3 { + subgraph A { + subgraph Aa{ + Aa1[label = "", shape = circle] + Aa2[label = "", shape = circle] + Aa3[label = "", shape = circle] + + Aa1--Aa2--Aa3 + } + subgraph Ab{ + Ab1[label = "", shape = circle] + Ab2[label = "", shape = circle] + Ab3[label = "", shape = circle] + + Ab1--Ab2 + Ab1--Ab3 + } + } + subgraph B { + subgraph Ba{ + Ba1[label = "", shape = circle] + Ba1[label = "", shape = circle] + Ba2[label = "", shape = circle] + Ba3[label = "", shape = circle] + + Ba1--Ba2--Ba3 + } + } +} \ No newline at end of file