What sort does Java Collections.sort(nodes) use?

后端 未结 4 1243
耶瑟儿~
耶瑟儿~ 2020-12-01 10:11

I think it is MergeSort, which is O(n log n).

However, the following output disagrees:

-1,0000000099000391,0000000099000427
1,0000000099000427,000000         


        
4条回答
  •  误落风尘
    2020-12-01 10:30

    O(n log n) doesn't mean that the number of comparisons will be equal to or less than n log n, just that the time taken will scale proportionally to n log n. Try doing tests with 8 nodes, or 16 nodes, or 32 nodes, and checking out the timing.

提交回复
热议问题