How can you sort an array? - Cracking the Java Coding Interview

preview_player
Показать описание
Cracking the #Java #Coding #Interview - Question 7: How can you sort an array?
Рекомендации по теме
Комментарии
Автор

Arrays.parallelSort() FTW.

HeapSort and QuickSort would not work for Object[], because the sort is not stable. Heap sorting is used in PriorityQueue. Instead they use TimSort since Java 7. Prior to that they used MergeSort. TimSort is better for partially sorted lists.

For primitive arrays short[], byte[] and char[], the Arrays.sort() might use radix sort instead of the dual-pivot quick sort.

As for job interviews, I would refuse to work for a company that asked me to implement BubbleSort for them ;-)

heinzkabutz
Автор

I sorted an array with Arrays.sort() in an interview and got rejected. Next time I'm gonna school the interviewer with the link to this video.

ShinAkuma
Автор

Big thanks for your work! But please, please make the sound of shorts more higher 🙏

seregaforeverserega
Автор

"Don't write your own Algorithm" until you need a indirect sort... Then you can't avoid it...
Or have to duplicate the array and then compare the indexes to make a indirect sort work.

Speiger
Автор

If one uses array.sort() in the interview, they get rejected from the application process. When sorting an array in an interview, one always needs to write their own algorithm.

guitarman
Автор

How come I dont understand any of these tips?

Aswodel