Sort Wars: Quick Sort vs Heap Sort

preview_player
Показать описание
Quick and Heap Sort are efficient sorting algorithms, so we used 4x larger array than with bubble, select and insertion sort.
Quick Sort performance heavily depends on how pivot is being picked. In this video we look at start middle and end of every sorted subset and algorithm picks the best one of three candidates. Not the best method, but improves speed in some cases.

Heap Sort performance isn't impacted by array randomness, but it also won't also benefit from any cases.

Still both are better than simple sorting algorithms.
Комментарии
Автор

Best case for heapsort is probably already in a heap and using either minheap or maxheap depending on the direction it is already sorted in. What you should do is take out the visualizations, and time some really big array of the SAME initial values for both sorts and make a table of the actual times. For example, case 1 might be to generate 1 million random numbers and store them in an array, then have both heapsort and quicksort sort the same 1 million values (exact copies) and see who wins (remember no visualizations), then try the same for a semi sorted array, small value array, array of strings, array of real numbers.... This test here is inconclusive.

davidjames
Автор

I think something is wrong with heap sort, why does it switch in a sorted array?

MrKosynus
Автор

try hash sort, choose the number of bins correctly, its like the radix sort

Jkauppa
Автор

"Quicksort (X-Search)" would always have been faster. It always divides the current recursion into three ranges: Less than..., identical to... and greater than pivot.

martinsgaming-kanal
Автор

Heapsort WILL benefit from certain cases and heapsort is NOT better than all simple sorts. Counting sort for example will sort a small range of numbers quicker such as numbers in the 0 to 255 range. Downvoted for inaccuracy.

davidjames