Write an algorithm that will decide which sorting algorithm (between bubbleSort, mergeSort and quickSort (with middle pivot)) to give the input array for sorting. Suppose I choose the following benchmarks: - Random - Nearly sorted (i.e. nearly sorted in ascending order) - Reversed (i.e. nearly sorted in descending order) - Few unique keys (i.e. contains repetitions due to few unique keys) From this benchmark set, which benchmark property constraints can hold up, in order to support the claim, for choosing either "bubbleSort", "mergeSort" or "quickSort"?
bubble sort works good for a nearly sorted list
i think merge sort would work well for a reverse order list
quick sort works well in general, but not so good if there are only a few unique keys
Join our real-time social learning platform and learn together with your friends!