-->
当前位置:首页 > 题库

单选题:A Red-black tree performs Insert or delete in the worst case $a_

Luz4年前 (2022-06-30)题库653
A $n$-nodes Red-black tree $T$ performs insertion or deletion in the worst case that costs $a_1 \lg n +b_1$, $a_2 \lg n + b_2$, respectively, where $a_1, a_2, b_1, b_2$ are constants. Now, we start from an empty tree, perform a sequence of $n$ insertions or deletions in the Red-black tree. To analysis the amortized cost per insertion or deletion, we define a potential function $\Phi(T) = a_2 \sum_{i=1}^{n} \lg i$. What is the amortized cost per insertion or deletion?






A.$O(\lg n )$ for insertion $O(\lg n)$ for deletion
B.$O(\lg n )$ for insertion $O(1)$ for deletion
C.$O(1)$ for insertion, $O(\lg n)$ for deletion
D.$O(1)$ for insertion, $O(1)$ for deletion


答案:B