Comparison costs of B-tree erasure #
eraseQ, eraseMinQ and eraseMaxQ instantiate eraseM, eraseMinM and eraseMaxM at
FreeM (LEQuery α) with the query interface LEQuery.ask and visit := pure (), in the
comparison-query model of Cslib.DataStructure.BTree.Comparisons.Query.
Erasure compares keys only while it scans the nodes of its search path, one node per level: at
most one comparison per triple passed and a second at the triple where the scan stops, so at most
rest.length + 1 at a node. Everything else it does is free of comparisons. The repairs
rebalanceRightM and rebalanceLastM and the removal popMinM of the successor of an interior
key take no comparator, and neither do minM and maxM, which find the entry that eraseMinM
and eraseMaxM remove. The comparison bound of all three operations is therefore that of
insertion, 2 * t * height, and not the node-visit counts 2 * height and 3 * height
times the per-node bound 2 * t: the siblings that a
repair visits, the path to the successor and the pass to the extreme entry are visited without
comparing keys.
The bounds hold under every oracle, but only on well-formed trees: a node of a raw tree may hold
more than 2 * t - 1 keys.
Main definitions #
Main results #
eval_eraseQ,eval_eraseMinQ,eval_eraseMaxQ: the values underorderOracleareerase,eraseMin?anderaseMax?.countQueries_eraseQ_le,countQueries_eraseMinQ_le,countQueries_eraseMaxQ_le: at most2 * t * heightcomparisons on a well-formed tree, under any oracle.countQueries_eraseQ_le_log,countQueries_eraseMinQ_le_log,countQueries_eraseMaxQ_le_log: withIsWF.height_le_log.eraseQ_upperBound,eraseMinQ_upperBound,eraseMaxQ_upperBound: theUpperBoundpackaging.
References #
Erasure, counting comparisons.
Under the order's oracle, eraseQ evaluates to the pure erasure erase.
Under the order's oracle, eraseMinQ evaluates to eraseMin?.
Under the order's oracle, eraseMaxQ evaluates to eraseMax?.
Erasure from the empty tree makes no comparisons.
Removing the least entry of the empty tree makes no comparisons.
Removing the greatest entry of the empty tree makes no comparisons.
Erasure makes at most 2 * t * height comparisons: it scans one node per level, and its
repairs and the removal of a successor compare no keys.
Removing the least entry makes at most 2 * t * height comparisons: finding it makes none,
and the rest is the erasure of its key.
Removing the greatest entry makes at most 2 * t * height comparisons: finding it makes
none, and the rest is the erasure of its key.
Erasure from a well-formed tree makes logarithmically many comparisons.
Removing the least entry of a well-formed tree makes logarithmically many comparisons.
Removing the greatest entry of a well-formed tree makes logarithmically many comparisons.
UpperBound packaging for eraseQ, on well-formed trees.
UpperBound packaging for eraseMinQ, on well-formed trees.
UpperBound packaging for eraseMaxQ, on well-formed trees.