Binary search vs binary search tree

后端 未结 4 1556
我寻月下人不归
我寻月下人不归 2021-01-31 03:16

What is the benefit of a binary search tree over a sorted array with binary search? Just with mathematical analysis I do not see a difference, so I assume there must be a diffe

4条回答
  •  旧时难觅i
    2021-01-31 04:01

    There's not much of a benefit in querying either one.

    But constructing a sorted tree is a lot faster than constructing a sorted array, when you're adding elements one at a time. So there's no point in converting it to an array when you're done.

提交回复
热议问题