Documentation

Batteries.Data.RBMap.Depth

RBNode depth bounds #

def Batteries.RBNode.depth {α : Type u_1} :
RBNode αNat

O(n). depth t is the maximum number of nodes on any path to a leaf. It is an upper bound on most tree operations.

Equations
Instances For
    theorem Batteries.RBNode.size_lt_depth {α : Type u_1} (t : RBNode α) :
    t.size < 2 ^ t.depth

    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

      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 : RBColor) (n : Nat) :
        depthUB c n 2 * n + 1
        theorem Batteries.RBNode.Balanced.depth_le {α : Type u_1} {t : RBNode α} {c : RBColor} {n : Nat} :
        t.Balanced c nt.depth depthUB c n
        theorem Batteries.RBNode.Balanced.le_size {α : Type u_1} {t : RBNode α} {c : RBColor} {n : Nat} :
        t.Balanced c n2 ^ depthLB c n t.size + 1
        theorem Batteries.RBNode.Balanced.depth_bound {α : Type u_1} {t : RBNode α} {c : RBColor} {n : Nat} (h : t.Balanced c n) :
        t.depth 2 * (t.size + 1).log2
        theorem Batteries.RBNode.WF.depth_bound {α : Type u_1} {cmp : ααOrdering} {t : RBNode α} (h : WF cmp t) :
        t.depth 2 * (t.size + 1).log2

        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.