English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Java Collections.sort() uses mergesort while Arrays.sort() uses quicksort. What's the rationale for the different choices? Is this from some difference between collection and array?

2007-02-21 11:05:59 · 2 answers · asked by Yuman 4 in Computers & Internet Software

2 answers

I believe you are mistaken. The Arrays.sort() methods for primitives use a type of quicksort that gives n*log(n) performance. The Arrays.sort() methods that act on Objects use a mergesort (n*log(n)), just like Collections.sort().

2007-02-22 18:09:20 · answer #1 · answered by vincentgl 5 · 0 0

Yeah equipment.currentTimeMillis(); like this long start up=equipment.currnetTimeMillis(); //your code equipment.out.println("Time taken is "+(equipment.currentTimeMillis()-start up)); this might provide term in milliseconds confirm to take long no longer int

2016-10-16 05:04:43 · answer #2 · answered by ? 4 · 0 0

fedest.com, questions and answers