RBNode depth bounds #
depthLB c n
is the best upper bound on the depth of any balanced red-black tree
with root colored c
and black-height n
.
Equations
Instances For
theorem
Batteries.RBNode.depthLB_le
(c : Batteries.RBColor)
(n : Nat)
:
n ≤ Batteries.RBNode.depthLB c n
depthUB c n
is the best upper bound on the depth of any balanced red-black tree
with root colored c
and black-height n
.
Equations
Instances For
theorem
Batteries.RBNode.depthUB_le
(c : Batteries.RBColor)
(n : Nat)
:
Batteries.RBNode.depthUB c n ≤ 2 * n + 1
theorem
Batteries.RBNode.depthUB_le_two_depthLB
(c : Batteries.RBColor)
(n : Nat)
:
Batteries.RBNode.depthUB c n ≤ 2 * Batteries.RBNode.depthLB c n
theorem
Batteries.RBNode.Balanced.depth_le
{α : Type u_1}
{t : Batteries.RBNode α}
{c : Batteries.RBColor}
{n : Nat}
:
t.Balanced c n → t.depth ≤ Batteries.RBNode.depthUB c n
theorem
Batteries.RBNode.Balanced.le_size
{α : Type u_1}
{t : Batteries.RBNode α}
{c : Batteries.RBColor}
{n : Nat}
:
t.Balanced c n → 2 ^ Batteries.RBNode.depthLB c n ≤ t.size + 1
theorem
Batteries.RBNode.Balanced.depth_bound
{α : Type u_1}
{t : Batteries.RBNode α}
{c : Batteries.RBColor}
{n : Nat}
(h : t.Balanced c n)
:
theorem
Batteries.RBNode.WF.depth_bound
{α : Type u_1}
{cmp : α → α → Ordering}
{t : Batteries.RBNode α}
(h : Batteries.RBNode.WF cmp t)
:
A well formed tree has t.depth ∈ O(log t.size)
, that is, it is well balanced.
This justifies the O(log n)
bounds on most searching operations of RBSet
.