thanks for your reply, but can you please also provide, real examples like, video streaming data sort, search addresses of people with first name starting with K in an phone dirctory record of over 5 million people.
–
AmeyJun 13 '12 at 20:33

2 Answers
2

As the number of elements increases, you will use more sophisticated sorting algorithms. The later sorting techniques have a higher initial overhead, so you need a lot of elements to sort to justify that cost. If you only have 10 elements, a bubble or insertion sort will be the much faster than a merge sort, or heapsort.

Space complexity is important to consider for smaller embedded devices like a TV remote, or a cell phone. You don't have enough space to do something like a heapsort on those devices.

Datebases use an external merge sort to sort sets of data that are too large to be loaded entirely into memory. The driving factor in this sort is the reduction in the number of disk I/Os.

thank you for your reply, so at no point will one ever have to use bubble sort or insertion sort in a real world scenario?
–
AmeyJun 13 '12 at 20:35

If you know that you do not have very many items to sort, it is better to use bubble sort or insertion sort. I programmed a TV remote that used a MIPS processor and I used bubble sort to sort the channels on the longest viewing time. There were only 100 channels. Also, if you know the elements are in near-sorted order, a bubble sort is good because it will finish in a far better speed than average case of n/2 passes.
–
JustinDanielsonJun 13 '12 at 20:39

Thanks Justin, do you want to edit it (the bubble sort part) into your result. I am marking this as the answer.
–
AmeyJun 13 '12 at 21:15

The GNU Standard C++ library, for example, uses a hybrid sorting
algorithm: introsort is performed first, to a maximum depth given by
2×log2 n, where n is the number of elements, followed by an insertion
sort on the result.1 Whatever the implementation, the complexity
should be O(n log n) comparisons on the average.[2]