MCPcopy Index your code
hub / github.com/douchuan/algorithm / height

Function height

tests/test_rb_tree2.rs:6–14  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4
5#[test]
6fn height() {
7 let mut tree = Tree::default();
8 for v in 0..100 {
9 tree.insert(v, v);
10 }
11 // 即使输入升序数列,rb tree仍然是平衡的
12 // 证明:含有n个节点的红黑树,其高度不会超过 2 * lg(n + 1)
13 assert!(tree.height() as f32 <= 2.0 * 100.0f32.log2())
14}
15
16/// Algorithms 4th Edition by Robert Sedgewick, Kevin Wayne
17/// P440

Callers

nothing calls this directly

Calls 1

insertMethod · 0.45

Tested by

no test coverage detected