Search times for binary search tree

后端 未结 3 1907
太阳男子
太阳男子 2020-12-14 02:55

Does anyone know how to figure out search time for a binary search tree(i.e. worst-case, best-case, and average-case)?

3条回答
  •  情书的邮戳
    2020-12-14 03:55

    Best case is O(1). the first element could be the item you are looking for. worst case is O(n) ie in a skewed tree and average case is O(lg n).

提交回复
热议问题