Will Arrays.sort() increase time complexity and space time complexity?

后端 未结 4 1241
小蘑菇
小蘑菇 2020-12-08 08:44

There is an array related problem, the requirement is that time complexity is O(n) and space complexity is O(1).

If I use Arrays.sort(arr), and use a

4条回答
  •  没有蜡笔的小新
    2020-12-08 09:02

    It is more than O(n) time and requires more than O(1) space.

    Arrays.sort() utilizes a modified Timsort in 1.7 which is a relatively recently developed sorting algorithm and it offers sorting with complexity x where O(n)< x < O(nlgn) and space of O(n/2)

提交回复
热议问题