Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What sorting algorithm fit this 'stream-like' condition?

I have a buffer receiving data, which means the data are like 'stream' and have latency in 'IO'. The way I am doing now is when the buffer is full, using qsort to sort the buffer and write the result to disk. but there is obvious latency when doing qsort, so I am looking for some other sorting algorithms that may start sorting while the data is being added to the buffer, in order to reduce time consumed overall.

don't know if I have made myself clear and leave any comments if needed, thanks

like image 712
Mickey Shine Avatar asked Mar 09 '12 13:03

Mickey Shine


People also ask

What is the algorithm used to sort streaming data?

Recently, Chaikhan et al. [34] proposed an algorithm called streaming data sort to continuously sort incoming big streaming data by using a uniprocessor and only one internal fixed-size working memory.

Which sorting algorithm is best suited if the elements are already sorted?

Merge Sort Was this answer helpful?

Which algorithm type is best suited to sorting and scheduling problems?

2. Bubble Sort. This sorting algorithm is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in the wrong order. If we have total N elements, then we need to repeat the above process for N-1 times.

Which sorting algorithm is best for parallel?

Parallel Merge Sort Merge sort first divides the unsorted list into smallest possible sub-lists, compares it with the adjacent list, and merges it in a sorted order. It implements parallelism very nicely by following the divide and conquer algorithm.


1 Answers

Heap sort keeps the data permanently in a partially sorted condition and so is comparable to Insertion sort. But it is substantially quicker and has a worst case of O(n log n) compared with O(n2) for Insertion Sort.

How is this going to work? Presumably at some point you have to stop reading from the stream, store what you have sorted, and start reading a new set of data?

like image 151
Borodin Avatar answered Oct 20 '22 08:10

Borodin