作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在过去的一次考试中,我们曾经被要求通过查看树的形状来判断一棵树是否是红黑平衡的。我还没有找到任何关于如何做到这一点的信息,除了有人声称如果最长路径不超过最短路径的两倍,二叉树是红黑平衡的,但我很确定这是 null 的要求路径平衡树也是如此。那是对的吗?有没有办法通过形状判断一棵树是否是红黑平衡的?
最佳答案
我不是大师,但这是来自 Cormen 的书 Introduction to Algorithms
:
A red-black tree is a binary tree that satisfies the following red-black properties:
- Every node is either red or black.
- The root is black.
- Every leaf (NIL) is black.
- If a node is red, then both its children are black.
- For each node, all simple paths from the node to descendant leaves contain the same number of black nodes.
关于binary-tree - 如何判断二叉树是否是红黑平衡的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30159303/
我正在实现红黑 SOR 的并行版本。 我想获得每个进程的最大误差的 MPI_Allreduce 部分不起作用。它永远不会改变,即使只有一个过程,它也会给出高于 2.0 的值。怎么回事?? 这是代码,有
我为拉普拉斯方程(一个简单的加热板问题)在我的红黑 Gauss-Seidel 求解器中添加了 OpenACC 指令,但是 GPU 加速的代码并不比 CPU 快,即使对于大问题也是如此。 我还编写了一个
我是一名优秀的程序员,十分优秀!