Skip to content

Commit

Permalink
Merge pull request #171 from kestory/master
Browse files Browse the repository at this point in the history
fix typo
  • Loading branch information
Zhenchao Gan authored Oct 23, 2017
2 parents 7ea7d01 + 23b087c commit 5e4f537
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions C13-Red-Black-Trees/13.1.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### Exercises 13.1-1
***
In the style of Figure 13.1(a), draw the complete binary search tree of height 3 on the keys {1, 2, ..., 15}. Add the NIL leaves and color the nodes in three different ways such that the black- heights of the resulting red-black trees are 2, 3, and 4.
In the style of Figure 13.1(a), draw the complete binary search tree of height 3 on the keys {1, 2, ..., 15}. Add the NIL leaves and color the nodes in three different ways such that the black-heights of the resulting red-black trees are 2, 3, and 4.

### `Answer`
因为是一颗完全二叉树,超级平衡,所以填色很容易. 感谢[psu](http://test.scripts.psu.edu/users/d/j/djh300/cmpsc465/notes-4985903869437/solutions-to-some-homework-exercises-as-shared-with-students/3-solutions-clrs-13.pdf)提供的图片
Expand All @@ -12,10 +12,10 @@ In the style of Figure 13.1(a), draw the complete binary search tree of height 3
Draw the red-black tree that results after TREE-INSERT is called on the tree in Figure 13.1 with key 36. If the inserted node is colored red, is the resulting tree a red-black tree? What if it is colored black?

### `Answer`
插入后如何上红色,那么违反了红节点的儿子节点是黑色这个规则.
插入后如果上红色,那么违反了红节点的儿子节点是黑色这个规则.
![image](./repo/s1/2.png)

插入后如何上黑色,那么违反了路径上包含相同黑节点数这个规则.
插入后如果上黑色,那么违反了路径上包含相同黑节点数这个规则.
![image](./repo/s1/3.png)


Expand Down Expand Up @@ -48,6 +48,7 @@ length at most twice that of the shortest simple path from node x to a descendan
What is the largest possible number of internal nodes in a red-black tree with black-height *k*? What is the smallest possible number?

### `Answer`

假如有一颗完美二叉树,如果每个节点都是黑的. 这种情况下, 节点数最小, 是 ![](http://latex.codecogs.com/gif.latex?2^k-1)

The smallest possible number of internal nodes is ![](http://latex.codecogs.com/gif.latex?2^k-1). When it's a complete binary tree with k levels with all nodes black.
Expand Down

0 comments on commit 5e4f537

Please sign in to comment.