Sort And Searching Question:

Download Job Interview Questions and Answers PDF

Tell me are there implementations for sorting and searching in the Java libarary?

Sort And Searching Interview Question
Sort And Searching Interview Question

Answer:

Yes. The Java library java.util.Arrays contains the methods Arrays.sort() and Arrays.binarySearch() that implement mergesort and binary search for Comparable types and a sorting implementation for primitive types based on a version of the quicksort algorithm, which is faster than mergesort and also sorts an array in place (without using any extra space). SystemSort.java illustrates how to use Arrays.sort().

Download Sort And Searching Interview Questions And Answers PDF

Previous QuestionNext Question
What is Quicksort?Do you know why doesn't the Java library use a randomized version of quicksort?