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

Function rb_tree_height

tests/test_rb_tree.rs:4–13  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

insertMethod · 0.45

Tested by

no test coverage detected