Beruflich Dokumente
Kultur Dokumente
<
= cnlogn
Thus building a red-black tree has O(nlogn)
>
= cn/2 * (logn 1)
Thus building a red-black tree has (nlogn).
Thus building a red-black tree has (nlogn) running time.
InorderTreeWalk would takes (n) times. Running time for SortRed-BlackTree is then:
T(n) = anlogn + bn (a, b are positive constant)
Thus T(n) has (nlogn) running time.
c) For an imbalanced binary search tree. Building the tree from Insert functions would
then take (n*height) of the tree. In the worst case, the height is of order O(n), thus
building the tree would then takes O(n
2
) time. InorderTreeWalk would still take (n)
time. Thus worst case running time for sorting using a simple (not necessarily balanced)
binary search tree would then take O(n
2
) time.