What is the worst case complexity for bucket sort?

前端 未结 5 1878
陌清茗
陌清茗 2021-01-02 11:57

I just read the Wikipedia page about Bucket sort. In this article they say that the worst case complexity is O(n²). But I thought the worst case complexity was O(n + k) wher

5条回答
  •  伪装坚强ぢ
    2021-01-02 12:29

    If you can guarantee that each bucket represents a unique value (equivalent items), then the worst case time complexity would be O(m+n) as you pointed out.

提交回复
热议问题